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