Class: ExpediaApi::Entities::Package
- Inherits:
-
Object
- Object
- ExpediaApi::Entities::Package
- Defined in:
- lib/expedia_api/entities/package.rb
Instance Attribute Summary collapse
-
#flight ⇒ Object
Returns the value of attribute flight.
-
#hotel ⇒ Object
Returns the value of attribute hotel.
-
#raw_data ⇒ Object
readonly
Returns the value of attribute raw_data.
Instance Method Summary collapse
-
#details_url ⇒ Object
returns the details url for the package.
- #flight_index ⇒ Object
- #hotel_index ⇒ Object
-
#initialize(raw_data) ⇒ Package
constructor
A new instance of Package.
-
#price ⇒ Object
returns a money object including the price.
-
#savings ⇒ Object
returns a money object with the savings, nil if there are no savings.
Constructor Details
#initialize(raw_data) ⇒ Package
Returns a new instance of Package.
7 8 9 |
# File 'lib/expedia_api/entities/package.rb', line 7 def initialize(raw_data) @raw_data = raw_data || {} end |
Instance Attribute Details
#flight ⇒ Object
Returns the value of attribute flight.
4 5 6 |
# File 'lib/expedia_api/entities/package.rb', line 4 def flight @flight end |
#hotel ⇒ Object
Returns the value of attribute hotel.
4 5 6 |
# File 'lib/expedia_api/entities/package.rb', line 4 def hotel @hotel end |
#raw_data ⇒ Object (readonly)
Returns the value of attribute raw_data.
5 6 7 |
# File 'lib/expedia_api/entities/package.rb', line 5 def raw_data @raw_data end |
Instance Method Details
#details_url ⇒ Object
returns the details url for the package
38 39 40 |
# File 'lib/expedia_api/entities/package.rb', line 38 def details_url raw_data[:DetailsUrl] end |
#flight_index ⇒ Object
11 12 13 |
# File 'lib/expedia_api/entities/package.rb', line 11 def flight_index raw_data[:FlightReferenceIndex].to_i end |
#hotel_index ⇒ Object
15 16 17 |
# File 'lib/expedia_api/entities/package.rb', line 15 def hotel_index raw_data[:HotelReferenceIndex].to_i end |
#price ⇒ Object
returns a money object including the price. returns nil if there is no price
20 21 22 23 24 25 26 |
# File 'lib/expedia_api/entities/package.rb', line 20 def price if raw_data[:PackagePrice] && raw_data[:PackagePrice][:TotalPrice] Money.new(raw_data[:PackagePrice][:TotalPrice][:Value].to_f * 100, raw_data[:PackagePrice][:TotalPrice][:Currency]) else nil end end |
#savings ⇒ Object
returns a money object with the savings, nil if there are no savings.
29 30 31 32 33 34 35 |
# File 'lib/expedia_api/entities/package.rb', line 29 def savings if raw_data[:PackagePrice] && raw_data[:PackagePrice][:TotalSavings] Money.new(raw_data[:PackagePrice][:TotalSavings][:Value].to_f * 100, raw_data[:PackagePrice][:TotalSavings][:Currency]) else nil end end |