Class: Weskit::WML::Items
- Includes:
- Enumerable, Mixins::Container, Mixins::Validator
- Defined in:
- lib/weskit/wml/items.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#contents ⇒ Object
readonly
Returns the value of attribute contents.
Instance Method Summary collapse
- #formatter ⇒ Object
- #formatter=(item) ⇒ Object
-
#initialize(*items) ⇒ Items
constructor
A new instance of Items.
- #to_s ⇒ Object (also: #to_str)
Methods included from Mixins::Container
#<<, #[], #attributes, #build, #delete, #elements, #exists?, #push
Methods included from Mixins::Validator
raise_if_invalid, raise_if_missing, raise_unless
Constructor Details
#initialize(*items) ⇒ Items
Returns a new instance of Items.
16 17 18 19 |
# File 'lib/weskit/wml/items.rb', line 16 def initialize *items @contents = [] push *items end |
Instance Attribute Details
#contents ⇒ Object (readonly)
Returns the value of attribute contents.
5 6 7 |
# File 'lib/weskit/wml/items.rb', line 5 def contents @contents end |
Instance Method Details
#formatter ⇒ Object
7 8 9 |
# File 'lib/weskit/wml/items.rb', line 7 def formatter @formatter or Formatter.default end |
#formatter=(item) ⇒ Object
11 12 13 14 |
# File 'lib/weskit/wml/items.rb', line 11 def formatter= item raise_unless Formatter, item @formatter = item end |
#to_s ⇒ Object Also known as: to_str
21 22 23 24 25 |
# File 'lib/weskit/wml/items.rb', line 21 def to_s @contents.collect do |item| formatter.format_detached item, formatter end.join formatter.separator end |