Sha256: dbf85f7dd854d8044166759dd6edc6dc3f676979f70e00908798174055325376
Contents?: true
Size: 1.86 KB
Versions: 5
Compression:
Stored size: 1.86 KB
Contents
module Ratis class Walkstop attr_accessor :legs, :walk_distance, :walk_units, :walk_time, :start_lat, :start_long, :end_lat, :end_long, :start_text, :end_text, :success 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 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 app_id = conditions.delete(:app_id) || 'ratis-gem' 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, 'Appid' => app_id Walkstop.new(response) end def to_hash keys = [:legs, :walk_distance, :walk_units, :walk_time] Hash[keys.map { |k| [k, send(k)] }] end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
ratis-3.4.3 | lib/ratis/walkstop.rb |
ratis-3.4.2 | lib/ratis/walkstop.rb |
ratis-3.4.1 | lib/ratis/walkstop.rb |
ratis-3.4.0 | lib/ratis/walkstop.rb |
ratis-3.3.7 | lib/ratis/walkstop.rb |