Class: Rome2rio::Route

Inherits:
Object
  • Object
show all
Defined in:
lib/rome2rio/response/route.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ Route

Returns a new instance of Route.



4
5
6
7
8
9
10
11
12
# File 'lib/rome2rio/response/route.rb', line 4

def initialize(json)
  @name = json["name"]
  @distance = json["distance"]
  @duration = json["duration"]
  @stops = []
  json["stops"].each { |stop| @stops << Stop.new(stop) }
  @segments = []
  json["segments"].each { |segment| @segments << Segment.new(segment) }
end

Instance Attribute Details

#distanceObject (readonly)

Returns the value of attribute distance.



3
4
5
# File 'lib/rome2rio/response/route.rb', line 3

def distance
  @distance
end

#durationObject (readonly)

Returns the value of attribute duration.



3
4
5
# File 'lib/rome2rio/response/route.rb', line 3

def duration
  @duration
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/rome2rio/response/route.rb', line 3

def name
  @name
end

#segmentsObject (readonly)

Returns the value of attribute segments.



3
4
5
# File 'lib/rome2rio/response/route.rb', line 3

def segments
  @segments
end

#stopsObject (readonly)

Returns the value of attribute stops.



3
4
5
# File 'lib/rome2rio/response/route.rb', line 3

def stops
  @stops
end