Class: Burlap::BaseTag
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
-
#name ⇒ Object
Returns the value of attribute name.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ BaseTag
constructor
A new instance of BaseTag.
- #parse_matched_pairs ⇒ Object
- #to_ruby ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ BaseTag
Returns a new instance of BaseTag.
6 7 8 9 10 11 |
# File 'lib/burlap/base_tag.rb', line 6 def initialize params={} params.each do |k,v| meffod = :"#{k}=" send(meffod, v) if respond_to?(meffod) end end |
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
4 5 6 |
# File 'lib/burlap/base_tag.rb', line 4 def children @children end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/burlap/base_tag.rb', line 4 def name @name end |
#value ⇒ Object
Returns the value of attribute value.
4 5 6 |
# File 'lib/burlap/base_tag.rb', line 4 def value @value end |
Instance Method Details
#parse_matched_pairs ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/burlap/base_tag.rb', line 21 def parse_matched_pairs # The children are matched pairs. # We use an array here because ruby 1.8.x is _FUN_ to # use ordered hashes with and doing it in an array is # easier for now. Viva la 1.9! values = [] self.children.each_slice(2) do |arr| key = arr.first.to_ruby value = if arr.last.name == "ref" i = arr.last.value.to_i - 1 v = values[i] v.last if v else arr.last.to_ruby end values << [key, value] end values end |