Class: Iface::ValueSet::Pair
- Inherits:
-
Object
- Object
- Iface::ValueSet::Pair
- Defined in:
- lib/iface/value_set.rb
Overview
Represents a NAME=value pair
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(line) ⇒ Pair
constructor
A new instance of Pair.
- #to_s ⇒ Object
Constructor Details
#initialize(line) ⇒ Pair
Returns a new instance of Pair.
10 11 12 13 14 15 |
# File 'lib/iface/value_set.rb', line 10 def initialize(line) match = line.match(/(^[A-Z0-9_]+)="?(.*?)"?$/) raise ArgumentError, "Expected pattern NAME=value; got #{line.inspect}" unless match @name = match[1] @value = match[2]&.sub(/^"/, '')&.sub(/"$/, '') end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/iface/value_set.rb', line 8 def name @name end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
8 9 10 |
# File 'lib/iface/value_set.rb', line 8 def value @value end |
Instance Method Details
#to_s ⇒ Object
17 18 19 |
# File 'lib/iface/value_set.rb', line 17 def to_s "#{@name}=\"#{@value}\"" end |