Class: Weskit::WML::Elements
- Includes:
- Mixins::Container, Mixins::Searchable
- Defined in:
- lib/weskit/wml/elements.rb
Instance Attribute Summary
Attributes inherited from Items
Instance Method Summary collapse
- #<<(item) ⇒ Object
- #[](key) ⇒ Object
- #find(name, nested = true) ⇒ Object (also: #method_missing)
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 Items
#formatter, #formatter=, #initialize, #to_s
Constructor Details
This class inherits a constructor from Weskit::WML::Items
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing ⇒ Object
25 26 27 |
# File 'lib/weskit/wml/elements.rb', line 25 def find name, nested = true find_elements name, nested end |
Instance Method Details
#<<(item) ⇒ Object
15 16 17 18 19 |
# File 'lib/weskit/wml/elements.rb', line 15 def << item raise_unless Element, item item.amendment? ? append(item) : add(item) self end |
#[](key) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/weskit/wml/elements.rb', line 8 def [] key case key when Integer then contents[key] else contents[0][key] rescue nil end end |
#find(name, nested = true) ⇒ Object Also known as: method_missing
21 22 23 |
# File 'lib/weskit/wml/elements.rb', line 21 def find name, nested = true find_elements name, nested end |