Class: ExpediaApi::Entities::SearchEntity
- Inherits:
-
Object
- Object
- ExpediaApi::Entities::SearchEntity
- Defined in:
- lib/expedia_api/entities/search_entity.rb
Instance Attribute Summary collapse
-
#raw_data ⇒ Object
readonly
Returns the value of attribute raw_data.
Instance Method Summary collapse
- #available? ⇒ Boolean
- #currency ⇒ Object
- #expedia_id ⇒ Object
- #has_promotion? ⇒ Boolean
- #hotel_mandatory_taxes_and_fees ⇒ Object
- #hotel_mandatory_taxes_and_fees_currency ⇒ Object
- #id ⇒ Object
-
#initialize(raw_data) ⇒ SearchEntity
constructor
A new instance of SearchEntity.
- #promotion_currency ⇒ Object
- #promotion_text ⇒ Object
- #promotion_value ⇒ Object
- #sold_out? ⇒ Boolean
- #total_price_including_taxes ⇒ Object
Constructor Details
#initialize(raw_data) ⇒ SearchEntity
Returns a new instance of SearchEntity.
6 7 8 |
# File 'lib/expedia_api/entities/search_entity.rb', line 6 def initialize(raw_data) @raw_data = raw_data || {} end |
Instance Attribute Details
#raw_data ⇒ Object (readonly)
Returns the value of attribute raw_data.
4 5 6 |
# File 'lib/expedia_api/entities/search_entity.rb', line 4 def raw_data @raw_data end |
Instance Method Details
#available? ⇒ Boolean
10 11 12 13 14 15 16 |
# File 'lib/expedia_api/entities/search_entity.rb', line 10 def available? if raw_data[:Price] !!raw_data[:Price].fetch(:TotalRate, nil) else false end end |
#currency ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/expedia_api/entities/search_entity.rb', line 51 def currency if available? raw_data[:Price][:TotalRate][:Currency] else nil end end |
#expedia_id ⇒ Object
63 64 65 |
# File 'lib/expedia_api/entities/search_entity.rb', line 63 def expedia_id id end |
#has_promotion? ⇒ Boolean
67 68 69 |
# File 'lib/expedia_api/entities/search_entity.rb', line 67 def has_promotion? !!raw_data[:Promotion].fetch(:Amount, nil) end |
#hotel_mandatory_taxes_and_fees ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/expedia_api/entities/search_entity.rb', line 35 def hotel_mandatory_taxes_and_fees if raw_data[:HotelMandatoryTaxesAndFees] && raw_data[:HotelMandatoryTaxesAndFees][:Value] raw_data[:HotelMandatoryTaxesAndFees][:Value].to_f else nil end end |
#hotel_mandatory_taxes_and_fees_currency ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/expedia_api/entities/search_entity.rb', line 43 def hotel_mandatory_taxes_and_fees_currency if raw_data[:HotelMandatoryTaxesAndFees] && raw_data[:HotelMandatoryTaxesAndFees][:Currency] raw_data[:HotelMandatoryTaxesAndFees][:Currency] else nil end end |
#id ⇒ Object
59 60 61 |
# File 'lib/expedia_api/entities/search_entity.rb', line 59 def id raw_data[:HotelID].to_i end |
#promotion_currency ⇒ Object
87 88 89 90 91 92 93 |
# File 'lib/expedia_api/entities/search_entity.rb', line 87 def promotion_currency if has_promotion? raw_data[:Promotion][:Amount][:Currency] else nil end end |
#promotion_text ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/expedia_api/entities/search_entity.rb', line 71 def promotion_text if has_promotion? raw_data[:Promotion][:Description] else nil end end |
#promotion_value ⇒ Object
79 80 81 82 83 84 85 |
# File 'lib/expedia_api/entities/search_entity.rb', line 79 def promotion_value if has_promotion? raw_data[:Promotion][:Amount][:Value].to_f else nil end end |
#sold_out? ⇒ Boolean
18 19 20 |
# File 'lib/expedia_api/entities/search_entity.rb', line 18 def sold_out? !available? end |
#total_price_including_taxes ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/expedia_api/entities/search_entity.rb', line 22 def total_price_including_taxes if available? price = raw_data[:Price][:TotalRate][:Value].to_f if hotel_mandatory_taxes_and_fees price + hotel_mandatory_taxes_and_fees else price end else nil end end |