Class: GoogleMapsAPI::Core::Metric

Inherits:
Object
  • Object
show all
Defined in:
lib/google_maps_api/core/metric.rb

Direct Known Subclasses

Distance, Duration

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text, value) ⇒ Metric

Returns a new instance of Metric.



4
5
6
7
# File 'lib/google_maps_api/core/metric.rb', line 4

def initialize(text, value)
  @text = text.to_s
  @value = value.to_i
end

Instance Attribute Details

#textObject (readonly)

Returns the value of attribute text.



2
3
4
# File 'lib/google_maps_api/core/metric.rb', line 2

def text
  @text
end

#valueObject (readonly)

Returns the value of attribute value.



2
3
4
# File 'lib/google_maps_api/core/metric.rb', line 2

def value
  @value
end

Class Method Details

.from_hash(hash) ⇒ Object



17
18
19
# File 'lib/google_maps_api/core/metric.rb', line 17

def self.from_hash(hash)
  self.new(hash["text"], hash["value"])
end

Instance Method Details

#to_iObject



13
14
15
# File 'lib/google_maps_api/core/metric.rb', line 13

def to_i
  value
end

#to_sObject



9
10
11
# File 'lib/google_maps_api/core/metric.rb', line 9

def to_s
  text
end