Class: Rome2rio::EncodedNumberPair
- Inherits:
-
Object
- Object
- Rome2rio::EncodedNumberPair
- Defined in:
- lib/rome2rio/helper/encoded_number_pair.rb
Instance Attribute Summary collapse
-
#a ⇒ Object
Returns the value of attribute a.
-
#b ⇒ Object
Returns the value of attribute b.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(a = nil, b = nil) ⇒ EncodedNumberPair
constructor
A new instance of EncodedNumberPair.
- #to_s ⇒ Object
Constructor Details
#initialize(a = nil, b = nil) ⇒ EncodedNumberPair
Returns a new instance of EncodedNumberPair.
5 6 7 8 |
# File 'lib/rome2rio/helper/encoded_number_pair.rb', line 5 def initialize(a = nil, b = nil) @a = a @b = b end |
Instance Attribute Details
#a ⇒ Object
Returns the value of attribute a.
3 4 5 |
# File 'lib/rome2rio/helper/encoded_number_pair.rb', line 3 def a @a end |
#b ⇒ Object
Returns the value of attribute b.
3 4 5 |
# File 'lib/rome2rio/helper/encoded_number_pair.rb', line 3 def b @b end |
Class Method Details
.parse(str) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/rome2rio/helper/encoded_number_pair.rb', line 10 def self.parse(str) # failsafe for empty data return if not str or str.strip.length == 0 ret = new str.scan(/([\d\.]+), ([\d\.]+)/).collect { |a, b| ret.a, ret.b = a, b } ret end |
Instance Method Details
#to_s ⇒ Object
19 20 21 |
# File 'lib/rome2rio/helper/encoded_number_pair.rb', line 19 def to_s "#{a}, #{b}" end |