Class: Samovar::Many
- Inherits:
-
Object
- Object
- Samovar::Many
- Defined in:
- lib/samovar/many.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
-
#initialize(key, description, stop: /^-/) ⇒ Many
constructor
A new instance of Many.
- #parse(input) ⇒ Object
- #to_a ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(key, description, stop: /^-/) ⇒ Many
Returns a new instance of Many.
23 24 25 26 27 |
# File 'lib/samovar/many.rb', line 23 def initialize(key, description, stop: /^-/) @key = key @description = description @stop = stop end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
29 30 31 |
# File 'lib/samovar/many.rb', line 29 def key @key end |
Instance Method Details
#parse(input) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/samovar/many.rb', line 39 def parse(input) if @stop and stop_index = input.index{|item| @stop === item} input.shift(stop_index) else input.shift(input.size) end end |
#to_a ⇒ Object
35 36 37 |
# File 'lib/samovar/many.rb', line 35 def to_a [to_s, @description] end |
#to_s ⇒ Object
31 32 33 |
# File 'lib/samovar/many.rb', line 31 def to_s "<#{key}...>" end |