Class: TollBooth::RouteStep
- Inherits:
-
Object
- Object
- TollBooth::RouteStep
- Defined in:
- lib/toll_booth/route_step.rb
Overview
a direction to take for a given route direction steps have the following attributes
-
distance (in miles)
-
travel_time (in seconds)
-
latitude
-
longitude
-
html_description
-
description (html stripped)
Instance Attribute Summary collapse
-
#distance ⇒ Object
Returns the value of attribute distance.
-
#html_description ⇒ Object
Returns the value of attribute html_description.
-
#latitude ⇒ Object
Returns the value of attribute latitude.
-
#longitude ⇒ Object
Returns the value of attribute longitude.
-
#travel_time ⇒ Object
Returns the value of attribute travel_time.
Class Method Summary collapse
-
.parse(json) ⇒ Object
parses the step from the json supplied.
Instance Method Summary collapse
-
#description ⇒ String
strips any html from the html_description_attribute.
Instance Attribute Details
#distance ⇒ Object
Returns the value of attribute distance.
11 12 13 |
# File 'lib/toll_booth/route_step.rb', line 11 def distance @distance end |
#html_description ⇒ Object
Returns the value of attribute html_description.
11 12 13 |
# File 'lib/toll_booth/route_step.rb', line 11 def html_description @html_description end |
#latitude ⇒ Object
Returns the value of attribute latitude.
11 12 13 |
# File 'lib/toll_booth/route_step.rb', line 11 def latitude @latitude end |
#longitude ⇒ Object
Returns the value of attribute longitude.
11 12 13 |
# File 'lib/toll_booth/route_step.rb', line 11 def longitude @longitude end |
#travel_time ⇒ Object
Returns the value of attribute travel_time.
11 12 13 |
# File 'lib/toll_booth/route_step.rb', line 11 def travel_time @travel_time end |
Class Method Details
.parse(json) ⇒ Object
parses the step from the json supplied
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/toll_booth/route_step.rb', line 21 def parse(json) route_steps = [] json.each do |s| route_step = new route_step.html_description = s["descriptionHtml"] route_step.travel_time = s["Duration"]["seconds"] route_step.distance = s["Distance"]["html"] route_step.latitude = s["Point"]["coordinates"][0] route_step.longitude = s["Point"]["coordinates"][1] route_steps << route_step end route_steps end |
Instance Method Details
#description ⇒ String
strips any html from the html_description_attribute
15 16 17 |
# File 'lib/toll_booth/route_step.rb', line 15 def description @html_description.gsub(/<\/?[^>]*>/, "") end |