Class: Ratis::Walkstop
- Inherits:
-
Object
- Object
- Ratis::Walkstop
- Defined in:
- lib/ratis/walkstop.rb
Instance Attribute Summary collapse
-
#end_lat ⇒ Object
Returns the value of attribute end_lat.
-
#end_long ⇒ Object
Returns the value of attribute end_long.
-
#end_text ⇒ Object
Returns the value of attribute end_text.
-
#legs ⇒ Object
Returns the value of attribute legs.
-
#start_lat ⇒ Object
Returns the value of attribute start_lat.
-
#start_long ⇒ Object
Returns the value of attribute start_long.
-
#start_text ⇒ Object
Returns the value of attribute start_text.
-
#success ⇒ Object
Returns the value of attribute success.
-
#walk_distance ⇒ Object
Returns the value of attribute walk_distance.
-
#walk_time ⇒ Object
Returns the value of attribute walk_time.
-
#walk_units ⇒ Object
Returns the value of attribute walk_units.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(response) ⇒ Walkstop
constructor
A new instance of Walkstop.
- #to_hash ⇒ Object
Constructor Details
#initialize(response) ⇒ Walkstop
Returns a new instance of Walkstop.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ratis/walkstop.rb', line 9 def initialize(response) @success = response.success? @legs = [] if @success walkstop_response = response[:walkstop_response] @legs = response.to_array(:walkstop_response, :walk, :leg) @walk_distance = walkstop_response[:walkinfo][:walkdistance] @walk_units = walkstop_response[:walkinfo][:walkunits] @walk_time = walkstop_response[:walkinfo][:walktime] @start_text = walkstop_response[:starttext] @end_text = walkstop_response[:endtext] end end |
Instance Attribute Details
#end_lat ⇒ Object
Returns the value of attribute end_lat.
5 6 7 |
# File 'lib/ratis/walkstop.rb', line 5 def end_lat @end_lat end |
#end_long ⇒ Object
Returns the value of attribute end_long.
5 6 7 |
# File 'lib/ratis/walkstop.rb', line 5 def end_long @end_long end |
#end_text ⇒ Object
Returns the value of attribute end_text.
5 6 7 |
# File 'lib/ratis/walkstop.rb', line 5 def end_text @end_text end |
#legs ⇒ Object
Returns the value of attribute legs.
5 6 7 |
# File 'lib/ratis/walkstop.rb', line 5 def legs @legs end |
#start_lat ⇒ Object
Returns the value of attribute start_lat.
5 6 7 |
# File 'lib/ratis/walkstop.rb', line 5 def start_lat @start_lat end |
#start_long ⇒ Object
Returns the value of attribute start_long.
5 6 7 |
# File 'lib/ratis/walkstop.rb', line 5 def start_long @start_long end |
#start_text ⇒ Object
Returns the value of attribute start_text.
5 6 7 |
# File 'lib/ratis/walkstop.rb', line 5 def start_text @start_text end |
#success ⇒ Object
Returns the value of attribute success.
5 6 7 |
# File 'lib/ratis/walkstop.rb', line 5 def success @success end |
#walk_distance ⇒ Object
Returns the value of attribute walk_distance.
5 6 7 |
# File 'lib/ratis/walkstop.rb', line 5 def walk_distance @walk_distance end |
#walk_time ⇒ Object
Returns the value of attribute walk_time.
5 6 7 |
# File 'lib/ratis/walkstop.rb', line 5 def walk_time @walk_time end |
#walk_units ⇒ Object
Returns the value of attribute walk_units.
5 6 7 |
# File 'lib/ratis/walkstop.rb', line 5 def walk_units @walk_units end |
Class Method Details
.where(conditions) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ratis/walkstop.rb', line 24 def self.where(conditions) start_lat = conditions.delete :start_lat start_long = conditions.delete :start_long end_lat = conditions.delete :end_lat end_long = conditions.delete :end_long raise ArgumentError.new('You must provide a start_lat') unless start_lat raise ArgumentError.new('You must provide a start_long') unless start_long raise ArgumentError.new('You must provide an end_lat') unless end_lat raise ArgumentError.new('You must provide an end_long') unless end_long Ratis.all_conditions_used? conditions response = Request.get 'Walkstop', 'Startlat' => start_lat, 'Startlong' => start_long, 'Endlat' => end_lat, 'Endlong' => end_long Walkstop.new(response) end |
Instance Method Details
#to_hash ⇒ Object
46 47 48 49 |
# File 'lib/ratis/walkstop.rb', line 46 def to_hash keys = [:legs, :walk_distance, :walk_units, :walk_time] Hash[keys.map { |k| [k, send(k)] }] end |