# File lib/amrita/node.rb, line 407def tagname_symbol
@tagname
end
hid()
return id=... attribule value. It can be hide by +hide_hid!
# File lib/amrita/node.rb, line 412def hid
if @hide_hid
nilelseself[:id] orself[:ID]
endend
hide_hid!()
hide hid for internal use (expand).
# File lib/amrita/node.rb, line 421def hide_hid!
@hide_hid = trueend
tagclass()
# File lib/amrita/node.rb, line 425def tagclass
self[:class]
end
put_attr(a)
set attribule.
# File lib/amrita/node.rb, line 430def put_attr(a)
copy_on_write if @attrs.shared
case a
when Attr
if @attrs_hash[a.key_symbol]
self[a.key_symbol] = a.value
else
a = a.clone
@attrs << a
@attrs_hash[a.key_symbol] = a
endwhen AttrArray
a.each do |aa|
put_attr(aa)
endwhen Hash
a.each do |k, v|
put_attr(Attr.new(k, v))
endelse
raise " << not a Attr but a #{a.class}" unless a.kind_of?(Attr)
endend
<<(a, &block)
# File lib/amrita/node.rb, line 454def <<(a, &block)
put_attr(a)
init_body(&block) if block_given?
selfend
include_attr?(key)
test if it has attribule for key
# File lib/amrita/node.rb, line 461def include_attr?(key)
@attrs_hash.include?(key.intern)
end
[](key)
return attribule value for key
# File lib/amrita/node.rb, line 466def [](key)
a = @attrs_hash[key.intern]
if a
a.value
elsenilendend
[]=(key, value)
set attribule. delete it if value is nil
# File lib/amrita/node.rb, line 476def []=(key, value)
copy_on_write if @attrs.shared
key = key.intern
a = @attrs_hash[key]
if a
if value
a.value = value
else
delete_attr!(key)
endelse
put_attr(Attr.new(key,value)) if value
end
value
end
delete_attr!(key)
delete attribute of key
# File lib/amrita/node.rb, line 493def delete_attr!(key)
copy_on_write if @attrs.shared
key = key.intern
old_attrs = @attrs
@attrs = AttrArray.new
@attrs_hash = {}
old_attrs.each do |a|
put_attr(a) if a.key_symbol != key
endend
to_ruby()
# File lib/amrita/node.rb, line 504def to_ruby
ret = "e(:#{tagname}"
if attrs.size > 0
ret << ","
ret << attrs.collect { |a| a.to_ruby}.join(",")
end
ret << ") "
ret << "{ #{body.to_ruby} }" if body andnot body.kind_of?(NullNode)
ret
end