Module: MARC::GenericPullParser

Included in:
NokogiriReader
Defined in:
lib/marc/xml_parsers.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) characters(text)



60
61
62
63
64
65
66
# File 'lib/marc/xml_parsers.rb', line 60

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

- (Object) end_element_namespace(name, prefix = nil, uri = nil)



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/marc/xml_parsers.rb', line 68

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

- (Object) start_element_namespace(name, attributes = [], prefix = nil, uri = nil, ns = {})



41
# File 'lib/marc/xml_parsers.rb', line 41

def start_element_namespace name, attributes = [], prefix = nil, uri = nil, ns = {}

- (Object) yield_record

Returns our MARC::Record object to the #each block.



36
37
38
39
# File 'lib/marc/xml_parsers.rb', line 36

def yield_record
  @block.call(@record[:record])       
  @record[:record] = nil
end