Class: XmlParsable::Elements::RecordElement
- Inherits:
-
AbstractElement
- Object
- AbstractElement
- XmlParsable::Elements::RecordElement
- Defined in:
- lib/xmlparsable/elements/record.rb
Defined Under Namespace
Classes: Proxy
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #close(element, value) ⇒ Object
- #finalize ⇒ Object
-
#initialize(name, attributes, parent, target, parsers, arguments) ⇒ RecordElement
constructor
A new instance of RecordElement.
- #open(name, attributes) ⇒ Object
Methods inherited from AbstractElement
Constructor Details
#initialize(name, attributes, parent, target, parsers, arguments) ⇒ RecordElement
Returns a new instance of RecordElement.
6 7 8 9 |
# File 'lib/xmlparsable/elements/record.rb', line 6 def initialize(name, attributes, parent, target, parsers, arguments) @name, @attributes, @parent, @target, @parsers, @elements = name, attributes, parent, target, parsers, Hash.new{|h,k| h.fetch(k.to_sym, nil) } end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
4 5 6 |
# File 'lib/xmlparsable/elements/record.rb', line 4 def attributes @attributes end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/xmlparsable/elements/record.rb', line 4 def name @name end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
4 5 6 |
# File 'lib/xmlparsable/elements/record.rb', line 4 def parent @parent end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
4 5 6 |
# File 'lib/xmlparsable/elements/record.rb', line 4 def target @target end |
Instance Method Details
#close(element, value) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/xmlparsable/elements/record.rb', line 19 def close(element, value) parser, arguments = @parsers[element.name] if arguments.include?(:repeated) (@elements[element.name.to_sym] ||= []) << value else @elements[element.name.to_sym] = value end end |
#finalize ⇒ Object
29 30 31 32 33 |
# File 'lib/xmlparsable/elements/record.rb', line 29 def finalize @target.instance_variable_set(:@xmlattrs, @attributes) @target.instance_variable_set(:@xmlelems, @elements) @parent.close(self, @target) if @parent end |
#open(name, attributes) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/xmlparsable/elements/record.rb', line 11 def open(name, attributes) parser, *arguments = @parsers[name] if parser parser.new(name, attributes, self, *arguments) end end |