Class: Eiwa::Tag::Bag
Overview
For simple elements that contain child element_name, value pairs that could plop into a hash nicely
Instance Attribute Summary collapse
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Attributes inherited from Any
#characters, #parent, #tag_name
Instance Method Summary collapse
- #[](key) ⇒ Object
- #end_child(child) ⇒ Object
-
#initialize ⇒ Bag
constructor
A new instance of Bag.
Methods inherited from Any
#add_characters, #end_self, #start, #to_s
Constructor Details
#initialize ⇒ Bag
Returns a new instance of Bag.
7 8 9 |
# File 'lib/eiwa/tag/bag.rb', line 7 def initialize @values = {} end |
Instance Attribute Details
#values ⇒ Object (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 |