Class: GoogleMapsAPI::DistanceMatrix::Element
- Inherits:
-
Object
- Object
- GoogleMapsAPI::DistanceMatrix::Element
- Defined in:
- lib/google_maps_api/distance_matrix/element.rb
Instance Attribute Summary collapse
-
#distance ⇒ Object
readonly
Returns the value of attribute distance.
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(status, duration = nil, distance = nil) ⇒ Element
constructor
A new instance of Element.
Constructor Details
#initialize(status, duration = nil, distance = nil) ⇒ Element
Returns a new instance of Element.
4 5 6 7 8 |
# File 'lib/google_maps_api/distance_matrix/element.rb', line 4 def initialize(status, duration = nil, distance = nil) @status = status @duration = duration @distance = distance end |
Instance Attribute Details
#distance ⇒ Object (readonly)
Returns the value of attribute distance.
2 3 4 |
# File 'lib/google_maps_api/distance_matrix/element.rb', line 2 def distance @distance end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
2 3 4 |
# File 'lib/google_maps_api/distance_matrix/element.rb', line 2 def duration @duration end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
2 3 4 |
# File 'lib/google_maps_api/distance_matrix/element.rb', line 2 def status @status end |
Class Method Details
.from_hash(hash) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/google_maps_api/distance_matrix/element.rb', line 10 def self.from_hash(hash) if hash["status"] == "OK" new( hash["status"], GoogleMapsAPI::Core::Duration.from_hash(hash["duration"]), GoogleMapsAPI::Core::Distance.from_hash(hash["distance"]) ) else new(hash["status"]) end end |