:attrs |
[R] |
return attributes as AttrArray
CAUTION! never edit result of this method. use []= instead. because it may
be shared by other Elements.
|
:body |
[R] |
return body
|
:hide_amrita_id |
[R] |
CAUTION! internal use only
|
:tag_symbol |
[RW] |
|
ElementCommon
new(tagname_or_element, *attrs, &block)
|
Don't use Element.new. Use Amrita#e instead.
# File lib/amrita/node.rb, line 571
def initialize(tagname_or_element, *attrs, &block)
case tagname_or_element
when Element
set_tag(tagname_or_element.tag_symbol)
@attrs = tagname_or_element.attrs
@attrs.shared = true
@hide_amrita_id = tagname_or_element.hide_amrita_id
if block_given?
init_body(&block)
else
@body = tagname_or_element.body.clone
end
when Symbol, String
set_tag(tagname_or_element)
@attrs = AttrArray.new(*attrs)
@hide_amrita_id = false
if block_given?
init_body(&block)
else
@body = Null
end
else
raise "invalid param for Element #{tagname_or_element}"
end
end
# File lib/amrita/node.rb, line 597
def set_tag(t)
@tag_symbol = t.to_s.intern
end
hide hid for internal use (expand).
# File lib/amrita/node.rb, line 602
def hide_amrita_id!
@hide_amrita_id = true
end
# File lib/amrita/node.rb, line 606
def set_attrs(a)
@attrs = a
end
delete_if(&block) {|self| ...}
|
# File lib/amrita/node.rb, line 610
def delete_if(&block)
if yield(self)
Null
else
clone { body.delete_if(&block) }
end
end