class Rome2rio::EncodedNumberPair

Attributes

a[RW]
b[RW]

Public Class Methods

new(a = nil, b = nil) click to toggle source
# File lib/rome2rio/helper/encoded_number_pair.rb, line 5
def initialize(a = nil, b = nil)
  @a = a
  @b = b
end
parse(str) click to toggle source
# 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

Public Instance Methods

to_s() click to toggle source
# File lib/rome2rio/helper/encoded_number_pair.rb, line 19
def to_s
  "#{a}, #{b}"
end