Class: Weskit::WML::Element
- Includes:
- Mixins::Container, Mixins::Searchable, Mixins::Validator
- Defined in:
- lib/weskit/wml/element.rb
Instance Attribute Summary collapse
-
#contents ⇒ Object
readonly
Returns the value of attribute contents.
Attributes inherited from Item
Instance Method Summary collapse
- #<<(item) ⇒ Object
- #amendment=(bool) ⇒ Object
- #amendment? ⇒ Boolean
- #find(name, nested = false) ⇒ Object (also: #method_missing)
-
#initialize(name, defaults = {}) ⇒ Element
constructor
A new instance of Element.
Methods included from Mixins::Container
#[], #attributes, #build, #delete, #elements, #exists?, #push
Methods included from Mixins::Validator
raise_if_invalid, raise_if_missing, raise_unless
Methods included from Mixins::Searchable
#elements_recursively, #find_recursively
Methods inherited from Item
#<=>, #formatter=, identifier, #merge, #to_s
Constructor Details
#initialize(name, defaults = {}) ⇒ Element
Returns a new instance of Element.
29 30 31 32 |
# File 'lib/weskit/wml/element.rb', line 29 def initialize name, defaults = {} @amendment, @contents = false, [] super end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing ⇒ Object
27 28 29 |
# File 'lib/weskit/wml/element.rb', line 27 def find name, nested = false find_elements name, nested end |
Instance Attribute Details
#contents ⇒ Object (readonly)
Returns the value of attribute contents.
7 8 9 |
# File 'lib/weskit/wml/element.rb', line 7 def contents @contents end |
Instance Method Details
#<<(item) ⇒ Object
9 10 11 12 13 |
# File 'lib/weskit/wml/element.rb', line 9 def << item (append? item) ? append(item) : add(item) item.attach_to self self end |
#amendment=(bool) ⇒ Object
15 16 17 |
# File 'lib/weskit/wml/element.rb', line 15 def amendment= bool @amendment = bool ? true : false end |
#amendment? ⇒ Boolean
19 20 21 |
# File 'lib/weskit/wml/element.rb', line 19 def amendment? @amendment end |
#find(name, nested = false) ⇒ Object Also known as: method_missing
23 24 25 |
# File 'lib/weskit/wml/element.rb', line 23 def find name, nested = false find_elements name, nested end |