module MARC::GenericPullParser
Public Instance Methods
characters(text)
click to toggle source
# File lib/marc/xml_parsers.rb, line 64 def characters text case @current_element when :leader then @record[:record].leader = text when :field then @record[:field].value << text when :subfield then @record[:subfield].value << text end end
end_element_namespace(name, prefix = nil, uri = nil)
click to toggle source
# File lib/marc/xml_parsers.rb, line 72 def end_element_namespace name, prefix = nil, uri = nil @current_element = nil if uri == @ns case name.downcase when 'record' then yield_record when /(control|data)field/ @record[:record] << @record[:field] @record[:field] = nil @current_element = nil if @current_element == :field when 'subfield' @record[:field].append(@record[:subfield]) @record[:subfield] = nil @current_element = nil if @current_element == :subfield end end end
start_element_namespace(name, attributes = [], prefix = nil, uri = nil, ns = {})
click to toggle source
# File lib/marc/xml_parsers.rb, line 45 def start_element_namespace name, attributes = [], prefix = nil, uri = nil, ns = {} attributes = attributes_to_hash(attributes) if uri == @ns case name.downcase when 'record' then @record[:record] = MARC::Record.new when 'leader' then @current_element = :leader when 'controlfield' @current_element=:field @record[:field] = MARC::ControlField.new(attributes["tag"]) when 'datafield' @record[:field] = MARC::DataField.new(attributes["tag"], attributes['ind1'], attributes['ind2']) when 'subfield' @current_element=:subfield @record[:subfield] = MARC::Subfield.new(attributes['code']) end end end
yield_record()
click to toggle source
Returns our MARC::Record
object to the each block.
# File lib/marc/xml_parsers.rb, line 40 def yield_record @block.call(@record[:record]) @record[:record] = nil end