Class: SabreDevStudio::Flight::Shop::OutboundFlight

Inherits:
Object
  • Object
show all
Defined in:
lib/sabre_dev_studio-flight/shop/streamlined_itineraries.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(flight, price) ⇒ OutboundFlight

Returns a new instance of OutboundFlight.



182
183
184
185
186
187
188
# File 'lib/sabre_dev_studio-flight/shop/streamlined_itineraries.rb', line 182

def initialize(flight, price)
  @flight_uuid = flight.sha
  @min_price = @max_price = price
  @inbounds = []
  @duration = flight.duration
  @min_inbound_duration = @max_inbound_duration = nil
end

Instance Attribute Details

#durationObject (readonly)

Returns the value of attribute duration.



179
180
181
# File 'lib/sabre_dev_studio-flight/shop/streamlined_itineraries.rb', line 179

def duration
  @duration
end

#flight_uuidObject (readonly)

Returns the value of attribute flight_uuid.



179
180
181
# File 'lib/sabre_dev_studio-flight/shop/streamlined_itineraries.rb', line 179

def flight_uuid
  @flight_uuid
end

#inboundsObject (readonly)

Returns the value of attribute inbounds.



179
180
181
# File 'lib/sabre_dev_studio-flight/shop/streamlined_itineraries.rb', line 179

def inbounds
  @inbounds
end

#max_inbound_durationObject (readonly)

Returns the value of attribute max_inbound_duration.



179
180
181
# File 'lib/sabre_dev_studio-flight/shop/streamlined_itineraries.rb', line 179

def max_inbound_duration
  @max_inbound_duration
end

#max_priceObject (readonly)

Returns the value of attribute max_price.



179
180
181
# File 'lib/sabre_dev_studio-flight/shop/streamlined_itineraries.rb', line 179

def max_price
  @max_price
end

#min_inbound_durationObject (readonly)

Returns the value of attribute min_inbound_duration.



179
180
181
# File 'lib/sabre_dev_studio-flight/shop/streamlined_itineraries.rb', line 179

def min_inbound_duration
  @min_inbound_duration
end

#min_priceObject (readonly)

Returns the value of attribute min_price.



179
180
181
# File 'lib/sabre_dev_studio-flight/shop/streamlined_itineraries.rb', line 179

def min_price
  @min_price
end

Instance Method Details

#add_inbound_flight(flight, price) ⇒ Object



190
191
192
193
194
195
196
197
# File 'lib/sabre_dev_studio-flight/shop/streamlined_itineraries.rb', line 190

def add_inbound_flight(flight, price)
  set_min_price(price)
  set_inbound_duration(flight.duration)
  @inbounds << {
    flight_uuid: flight.sha,
    price: price
  }
end

#to_hashObject



199
200
201
202
203
204
205
206
207
208
209
# File 'lib/sabre_dev_studio-flight/shop/streamlined_itineraries.rb', line 199

def to_hash
  {
    flight_uuid: flight_uuid,
    min_price: min_price,
    max_price: max_price,
    duration: duration,
    min_inbound_duration: min_inbound_duration,
    max_inbound_duration: max_inbound_duration,
    inbounds: inbounds.uniq
  }
end