Class: GoogleMapsAPI::Directions::Step

Inherits:
Object
  • Object
show all
Extended by:
LegAndStepCommonBuilders
Defined in:
lib/google_maps_api/directions/step.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from LegAndStepCommonBuilders

build_coordinate, build_distance, build_duration

Constructor Details

#initialize(distance, duration, end_location, start_location, html_instructions, polyline, travel_mode) ⇒ Step

Returns a new instance of Step.



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/google_maps_api/directions/step.rb', line 10

def initialize(
  distance, duration, end_location,
  start_location, html_instructions, 
  polyline, travel_mode
)
  @distance = distance
  @duration = duration
  @end_location = end_location
  @start_location = start_location
  @html_instructions = html_instructions
  @polyline = polyline
  @travel_mode = travel_mode
end

Instance Attribute Details

#distanceObject (readonly)

Returns the value of attribute distance.



6
7
8
# File 'lib/google_maps_api/directions/step.rb', line 6

def distance
  @distance
end

#durationObject (readonly)

Returns the value of attribute duration.



6
7
8
# File 'lib/google_maps_api/directions/step.rb', line 6

def duration
  @duration
end

#end_locationObject (readonly)

Returns the value of attribute end_location.



6
7
8
# File 'lib/google_maps_api/directions/step.rb', line 6

def end_location
  @end_location
end

#html_instructionsObject (readonly)

Returns the value of attribute html_instructions.



6
7
8
# File 'lib/google_maps_api/directions/step.rb', line 6

def html_instructions
  @html_instructions
end

#polylineObject (readonly)

Returns the value of attribute polyline.



6
7
8
# File 'lib/google_maps_api/directions/step.rb', line 6

def polyline
  @polyline
end

#start_locationObject (readonly)

Returns the value of attribute start_location.



6
7
8
# File 'lib/google_maps_api/directions/step.rb', line 6

def start_location
  @start_location
end

#travel_modeObject (readonly)

Returns the value of attribute travel_mode.



6
7
8
# File 'lib/google_maps_api/directions/step.rb', line 6

def travel_mode
  @travel_mode
end

Class Method Details

.from_hash(hash) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/google_maps_api/directions/step.rb', line 24

def self.from_hash(hash)
  distance = build_distance(hash)
  duration = build_duration(hash)
  end_location = build_coordinate(hash["end_location"])
  start_location = build_coordinate(hash["start_location"])
  html_instructions = hash["html_instructions"]
  polyline = build_polyline(hash)
  travel_mode = hash["travel_mode"]

  self.new(
    distance, duration, end_location,
    start_location, html_instructions, 
    polyline, travel_mode
  )
end