Class: RMARC::Listener
- Inherits:
-
Object
- Object
- RMARC::Listener
- Defined in:
- lib/rmarc/marc_xml_reader.rb
Instance Method Summary collapse
-
#initialize(queue) ⇒ Listener
constructor
A new instance of Listener.
- #tag_end(name) ⇒ Object
- #tag_start(name, attrs) ⇒ Object
- #text(text) ⇒ Object
- #xmldecl(version, encoding, standalone) ⇒ Object
Constructor Details
#initialize(queue) ⇒ Listener
Returns a new instance of Listener.
86 87 88 |
# File 'lib/rmarc/marc_xml_reader.rb', line 86 def initialize(queue) @queue = queue end |
Instance Method Details
#tag_end(name) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/rmarc/marc_xml_reader.rb', line 57 def tag_end(name) re = /(\w+):(\w+)/ md = re.match(name) name = $2 if ($2 != nil) case name when "collection" @queue.has_next = false when "record" @queue.push(@record) when "leader" leader = Leader.new(@data) @data = "" @record.leader = leader when "controlfield" @field.data = @data @data = "" @record.add(@field) when "datafield" @record.add(@field) when "subfield" @subfield.data = @data @data = "" @field.add(@subfield) end end |
#tag_start(name, attrs) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rmarc/marc_xml_reader.rb', line 35 def tag_start(name, attrs) re = /(\w+):(\w+)/ md = re.match(name) name = $2 if ($2 != nil) case name when "collection" @queue.has_next = true when "record" @record = Record.new when "controlfield" @field = ControlField.new(attrs["tag"]) when "datafield" @field = DataField.new(attrs["tag"], attrs["ind1"], attrs["ind2"]) when "subfield" @subfield = Subfield.new(attrs["code"]) end end |
#text(text) ⇒ Object
53 54 55 |
# File 'lib/rmarc/marc_xml_reader.rb', line 53 def text(text) @data = text end |
#xmldecl(version, encoding, standalone) ⇒ Object
83 84 |
# File 'lib/rmarc/marc_xml_reader.rb', line 83 def xmldecl(version, encoding, standalone) end |