Class: TL::Offer
- Inherits:
-
Object
- Object
- TL::Offer
- Defined in:
- lib/TL/offer.rb
Overview
represents offer
Instance Attribute Summary collapse
-
#capacity ⇒ Object
Returns the value of attribute capacity.
-
#price ⇒ Object
Returns the value of attribute price.
-
#rate_plan_name ⇒ Object
Returns the value of attribute rate_plan_name.
-
#room_description ⇒ Object
Returns the value of attribute room_description.
-
#room_name ⇒ Object
Returns the value of attribute room_name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(price:, capacity:, room_name:, room_description:, rate_plan_name:) ⇒ Offer
constructor
A new instance of Offer.
Constructor Details
#initialize(price:, capacity:, room_name:, room_description:, rate_plan_name:) ⇒ Offer
Returns a new instance of Offer.
11 12 13 14 15 16 17 |
# File 'lib/TL/offer.rb', line 11 def initialize(price:, capacity:, room_name:, room_description:, rate_plan_name:) @price = price @capacity = capacity @room_name = room_name @room_description = room_description @rate_plan_name = rate_plan_name end |
Instance Attribute Details
#capacity ⇒ Object
Returns the value of attribute capacity.
9 10 11 |
# File 'lib/TL/offer.rb', line 9 def capacity @capacity end |
#price ⇒ Object
Returns the value of attribute price.
9 10 11 |
# File 'lib/TL/offer.rb', line 9 def price @price end |
#rate_plan_name ⇒ Object
Returns the value of attribute rate_plan_name.
9 10 11 |
# File 'lib/TL/offer.rb', line 9 def rate_plan_name @rate_plan_name end |
#room_description ⇒ Object
Returns the value of attribute room_description.
9 10 11 |
# File 'lib/TL/offer.rb', line 9 def room_description @room_description end |
#room_name ⇒ Object
Returns the value of attribute room_name.
9 10 11 |
# File 'lib/TL/offer.rb', line 9 def room_name @room_name end |
Class Method Details
.from_hash_collection(offers_hash, hotel_info) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/TL/offer.rb', line 19 def from_hash_collection(offers_hash, hotel_info) result = [] offers_hash.dig("room_stays").each do |offer_hash| rate_plan_code = offer_hash.dig("rate_plans").first.dig("code") rate_plan_name = find_rate_plan(hotel_info, rate_plan_code).dig("name") offer_hash.dig("room_types").each do |room_type| room = find_room_type(hotel_info, room_type.dig("code")) room_type.dig("placements").each do |placement| price = placement.dig("price_after_tax") capacity = placement.dig("capacity") room_name = room.dig("name") room_description = room.dig("description") result << Offer.new(price: price, capacity: capacity, room_name: room_name, room_description: room_description, rate_plan_name: rate_plan_name) end end end result end |