Class: Skyscanner::Route

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

Overview

Route info

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Route

Returns a new instance of Route.



9
10
11
12
# File 'lib/movlog/route.rb', line 9

def initialize(data)
  @meta = RouteMeta.new(data[:meta])
  @flights = data[:flights]
end

Instance Attribute Details

#flightsObject (readonly)

Returns the value of attribute flights.



7
8
9
# File 'lib/movlog/route.rb', line 7

def flights
  @flights
end

#metaObject (readonly)

Returns the value of attribute meta.



6
7
8
# File 'lib/movlog/route.rb', line 6

def meta
  @meta
end

Class Method Details

.find(meta) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/movlog/route.rb', line 14

def self.find(meta)
  route_info = RouteInfo.find(meta)
  data = {
    meta: meta,
    flights: route_info.parse_flights
  }
  new(data)
end

Instance Method Details

#to_hashObject



23
24
25
# File 'lib/movlog/route.rb', line 23

def to_hash
  { meta: @meta.to_hash, flights: @flights.to_hash }
end