Class Amrita::AttrArray
In: lib/amrita/node.rb
Parent: Object

Array of Attr s. It can hold body part for using as a model data for Node#expand. Amrita#a() method is a shortcut for Attr.new

Methods
add    new   
Attributes
:array  [R] 

If you call a() { ... }, block yields to body

:body  [R] 

If you call a() { ... }, block yields to body

:shared  [RW] 

internal use only, never touch it!

true if this instance is shared by two or more elements

Included modules
AttrArrayCommon
Public Class methods
new(*attrs, &block) {|| ...}

Don't use AttrArray.new use a() instead

# File lib/amrita/node.rb, line 218
    def initialize(*attrs, &block)
      @array = []
      @shared = false
      self << attrs

      if block_given?
        @body = yield 
      else
        @body = Null
      end
    end
Public Instance methods
add(*x)

add an Attr

# File lib/amrita/node.rb, line 231
    def add(*x)
      x.each do |a|
        case a
        when Hash
          a.each do |k, v|
            self << Attr.new(k, v)
          end
        when Attr
          @array << a
        when Array, AttrArray
          a.each do |aa|
            self << aa
          end
        else
          raise "can't accept #{a}"
        end
      end
      self
    end