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
- #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
30 31 32 33 34 35 36 |
# File 'lib/expedia_api/entities/search_entity.rb', line 30 def currency if available? raw_data[:Price][:TotalRate][:Currency] else nil end end |
#expedia_id ⇒ Object
42 43 44 |
# File 'lib/expedia_api/entities/search_entity.rb', line 42 def expedia_id id end |
#has_promotion? ⇒ Boolean
46 47 48 |
# File 'lib/expedia_api/entities/search_entity.rb', line 46 def has_promotion? !!raw_data[:Promotion].fetch(:Amount, nil) end |
#id ⇒ Object
38 39 40 |
# File 'lib/expedia_api/entities/search_entity.rb', line 38 def id raw_data[:HotelID].to_i end |
#promotion_currency ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/expedia_api/entities/search_entity.rb', line 66 def promotion_currency if has_promotion? raw_data[:Promotion][:Amount][:Currency] else nil end end |
#promotion_text ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/expedia_api/entities/search_entity.rb', line 50 def promotion_text if has_promotion? raw_data[:Promotion][:Description] else nil end end |
#promotion_value ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/expedia_api/entities/search_entity.rb', line 58 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 |
# File 'lib/expedia_api/entities/search_entity.rb', line 22 def total_price_including_taxes if available? raw_data[:Price][:TotalRate][:Value].to_f else nil end end |