Class: Rome2rio::Segment
- Inherits:
-
Object
- Object
- Rome2rio::Segment
- Defined in:
- lib/rome2rio/response/segment.rb
Instance Attribute Summary collapse
-
#distance ⇒ Object
readonly
Returns the value of attribute distance.
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#indicativePrice ⇒ Object
readonly
Returns the value of attribute indicativePrice.
-
#isImperial ⇒ Object
readonly
Returns the value of attribute isImperial.
-
#isMajor ⇒ Object
readonly
Returns the value of attribute isMajor.
-
#itineraries ⇒ Object
readonly
Returns the value of attribute itineraries.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#sCode ⇒ Object
readonly
Returns the value of attribute sCode.
-
#sName ⇒ Object
readonly
Returns the value of attribute sName.
-
#sPos ⇒ Object
readonly
Returns the value of attribute sPos.
-
#subkind ⇒ Object
readonly
Returns the value of attribute subkind.
-
#tCode ⇒ Object
readonly
Returns the value of attribute tCode.
-
#tName ⇒ Object
readonly
Returns the value of attribute tName.
-
#tPos ⇒ Object
readonly
Returns the value of attribute tPos.
Instance Method Summary collapse
-
#initialize(json) ⇒ Segment
constructor
A new instance of Segment.
Constructor Details
#initialize(json) ⇒ Segment
Returns a new instance of Segment.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rome2rio/response/segment.rb', line 5 def initialize(json) # Possible kinds: walk, car, train, bus, ferry, flight @kind = json["kind"] @isMajor = json["isMajor"] == 1 @distance = json["distance"] @duration = json["duration"] @indicativePrice = IndicativePrice.new(json["indicativePrice"]) if @kind != "flight" then @isImperial = json["isImperial"] == 1 @sName = json["sName"] @sPos = Position.parse(json["sPos"]) @tName = json["tName"] @tPos = Position.parse(json["tPos"]) @path = json["path"] else @sCode = json["sCode"] @tCode = json["tCode"] @itineraries = [] json["itineraries"].each { |itinerary| @itineraries << FlightItinerary.new(itinerary) } end if [ "train", "bus", "ferry" ].include?(@kind) then @subkind = json["subkind"] @itineraries = [] json["itineraries"].each { |itinerary| @itineraries << TransitItinerary.new(itinerary) } end end |
Instance Attribute Details
#distance ⇒ Object (readonly)
Returns the value of attribute distance.
3 4 5 |
# File 'lib/rome2rio/response/segment.rb', line 3 def distance @distance end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
3 4 5 |
# File 'lib/rome2rio/response/segment.rb', line 3 def duration @duration end |
#indicativePrice ⇒ Object (readonly)
Returns the value of attribute indicativePrice.
3 4 5 |
# File 'lib/rome2rio/response/segment.rb', line 3 def indicativePrice @indicativePrice end |
#isImperial ⇒ Object (readonly)
Returns the value of attribute isImperial.
3 4 5 |
# File 'lib/rome2rio/response/segment.rb', line 3 def isImperial @isImperial end |
#isMajor ⇒ Object (readonly)
Returns the value of attribute isMajor.
3 4 5 |
# File 'lib/rome2rio/response/segment.rb', line 3 def isMajor @isMajor end |
#itineraries ⇒ Object (readonly)
Returns the value of attribute itineraries.
3 4 5 |
# File 'lib/rome2rio/response/segment.rb', line 3 def itineraries @itineraries end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
3 4 5 |
# File 'lib/rome2rio/response/segment.rb', line 3 def kind @kind end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/rome2rio/response/segment.rb', line 3 def path @path end |
#sCode ⇒ Object (readonly)
Returns the value of attribute sCode.
3 4 5 |
# File 'lib/rome2rio/response/segment.rb', line 3 def sCode @sCode end |
#sName ⇒ Object (readonly)
Returns the value of attribute sName.
3 4 5 |
# File 'lib/rome2rio/response/segment.rb', line 3 def sName @sName end |
#sPos ⇒ Object (readonly)
Returns the value of attribute sPos.
3 4 5 |
# File 'lib/rome2rio/response/segment.rb', line 3 def sPos @sPos end |
#subkind ⇒ Object (readonly)
Returns the value of attribute subkind.
3 4 5 |
# File 'lib/rome2rio/response/segment.rb', line 3 def subkind @subkind end |
#tCode ⇒ Object (readonly)
Returns the value of attribute tCode.
3 4 5 |
# File 'lib/rome2rio/response/segment.rb', line 3 def tCode @tCode end |
#tName ⇒ Object (readonly)
Returns the value of attribute tName.
3 4 5 |
# File 'lib/rome2rio/response/segment.rb', line 3 def tName @tName end |
#tPos ⇒ Object (readonly)
Returns the value of attribute tPos.
3 4 5 |
# File 'lib/rome2rio/response/segment.rb', line 3 def tPos @tPos end |