Module Amrita::AttrArrayCommon
In: lib/amrita/node.rb
Methods
[]    []=    attr_by_key    clear    clone    dup    each    inspect    keys    size    to_hash    to_ruby    value_by_key   
Included modules
Enumerable
Public Instance methods
clone()
# File lib/amrita/node.rb, line 131
    def clone
      self.class.new(array.collect { |a| a.clone } )
    end
dup()
# File lib/amrita/node.rb, line 135
    def dup
      self.class.new(array.collect { |a|  a.clone } )
    end
inspect()
# File lib/amrita/node.rb, line 139
    def inspect
      to_ruby
    end
clear()
# File lib/amrita/node.rb, line 143
    def clear
      array.clear
    end
[](index)
# File lib/amrita/node.rb, line 147
    def [](index)
      array[index]
    end
[]=(index, val)
# File lib/amrita/node.rb, line 151
    def []=(index, val)
      array[index] = val
      val
    end
each(&block)

iterate on each Attr

# File lib/amrita/node.rb, line 157
    def each(&block)
      array.each(&block)
    end
size()
# File lib/amrita/node.rb, line 161
    def size
      array.size
    end
attr_by_key(key)
# File lib/amrita/node.rb, line 165
    def attr_by_key(key)
      each do |a| 
        return a if a.key_symbol == key 
      end
      nil
    end
value_by_key(key)
# File lib/amrita/node.rb, line 172
    def value_by_key(key)
      each do |a| 
        return a.value if a.key_symbol == key 
      end
      nil
    end
to_hash()
# File lib/amrita/node.rb, line 179
    def to_hash
      ret = {}
      each do |a|
        ret[a.key.intern] = a.value
      end
      ret
    end
keys()
# File lib/amrita/node.rb, line 187
    def keys
      collect { |a| a.key_symbol }
    end
to_ruby()
# File lib/amrita/node.rb, line 191
    def to_ruby
      ret = "a(" + array.collect {|a| "#{a.key_symbol.to_ruby}=>#{a.value.inspect}"}.join(", ") + ")"
      case body
      when nil, Null
      when Node
        ret += body.to_ruby
      else
        ret += body.inspect
      end
      ret
    end