Class: Eiwa::Tag::Bag

Inherits:
Any
  • Object
show all
Defined in:
lib/eiwa/tag/bag.rb

Overview

For simple elements that contain child element_name, value pairs that could plop into a hash nicely

Instance Attribute Summary collapse

Attributes inherited from Any

#characters, #parent, #tag_name

Instance Method Summary collapse

Methods inherited from Any

#add_characters, #end_self, #start, #to_s

Constructor Details

#initializeBag

Returns a new instance of Bag.



7
8
9
# File 'lib/eiwa/tag/bag.rb', line 7

def initialize
  @values = {}
end

Instance Attribute Details

#valuesObject (readonly)

Returns the value of attribute values.



5
6
7
# File 'lib/eiwa/tag/bag.rb', line 5

def values
  @values
end

Instance Method Details

#[](key) ⇒ Object



11
12
13
# File 'lib/eiwa/tag/bag.rb', line 11

def [](key)
  @values[key]
end

#end_child(child) ⇒ Object



15
16
17
18
# File 'lib/eiwa/tag/bag.rb', line 15

def end_child(child)
  # Don't overwrite, first dupe tends to be authorative one
  @values[child.tag_name] = child.text unless @values.key?(child.tag_name)
end