Class: XmlParsable::Elements::ArrayElement

Inherits:
AbstractElement show all
Defined in:
lib/xmlparsable/elements/array.rb

Defined Under Namespace

Classes: Array

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractElement

#comment, parsable, #read

Constructor Details

#initialize(name, attributes, parent, arguments) ⇒ ArrayElement

Returns a new instance of ArrayElement.



12
13
14
15
16
17
18
19
# File 'lib/xmlparsable/elements/array.rb', line 12

def initialize(name, attributes, parent, arguments)
  @name, @attributes, @parent, @elements =
    name, attributes, parent, Array.new

  @item_name = arguments[:item_name].to_s
  @item_type = arguments[:class]
  @item_args = arguments[:item]
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/xmlparsable/elements/array.rb', line 10

def name
  @name
end

Instance Method Details

#close(element, value) ⇒ Object



27
28
29
# File 'lib/xmlparsable/elements/array.rb', line 27

def close(element, value)
  @elements << value
end

#finalizeObject



31
32
33
34
# File 'lib/xmlparsable/elements/array.rb', line 31

def finalize
  @elements.instance_variable_set(:@xmlattrs, @attributes)
  @parent.close(self, @elements)
end

#open(name, attributes) ⇒ Object



21
22
23
24
25
# File 'lib/xmlparsable/elements/array.rb', line 21

def open(name, attributes)
  if name == @item_name
    @item_type.parsable.new(name, attributes, self, @item_args)
  end
end