Class: GoogleMapsAPI::Directions::Leg

Inherits:
Object
  • Object
show all
Extended by:
LegAndStepCommonBuilders
Defined in:
lib/google_maps_api/directions/leg.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_address, end_location, start_address, start_location, steps, via_waypoint) ⇒ Leg

Returns a new instance of Leg.



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

def initialize(
  distance, duration, end_address, end_location,
  start_address, start_location, steps, via_waypoint
)
  @distance = distance
  @duration = duration
  @end_address = end_address
  @end_location = end_location
  @start_address = start_address
  @start_location = start_location
  @steps = steps
  @via_waypoint = via_waypoint
end

Instance Attribute Details

#distanceObject (readonly)

Returns the value of attribute distance.



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

def distance
  @distance
end

#durationObject (readonly)

Returns the value of attribute duration.



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

def duration
  @duration
end

#end_addressObject (readonly)

Returns the value of attribute end_address.



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

def end_address
  @end_address
end

#end_locationObject (readonly)

Returns the value of attribute end_location.



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

def end_location
  @end_location
end

#start_addressObject (readonly)

Returns the value of attribute start_address.



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

def start_address
  @start_address
end

#start_locationObject (readonly)

Returns the value of attribute start_location.



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

def start_location
  @start_location
end

#stepsObject (readonly)

Returns the value of attribute steps.



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

def steps
  @steps
end

#via_waypointObject (readonly)

Returns the value of attribute via_waypoint.



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

def via_waypoint
  @via_waypoint
end

Class Method Details

.from_hash(hash) ⇒ Object



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

def self.from_hash(hash)
  distance = build_distance(hash)
  duration = build_duration(hash)
  end_address = hash["end_address"]
  end_location = build_coordinate(hash["end_location"])
  start_address = hash["start_address"]
  start_location = build_coordinate(hash["start_location"])
  steps = build_steps(hash)
  via_waypoint = hash["via_waypoint"]

  self.new(
    distance, duration, end_address, end_location,
    start_address, start_location, steps, via_waypoint
  )
end