Class: ExpediaApi::Entities::Package

Inherits:
Object
  • Object
show all
Defined in:
lib/expedia_api/entities/package.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#flightObject

Returns the value of attribute flight.



4
5
6
# File 'lib/expedia_api/entities/package.rb', line 4

def flight
  @flight
end

#hotelObject

Returns the value of attribute hotel.



4
5
6
# File 'lib/expedia_api/entities/package.rb', line 4

def hotel
  @hotel
end

#raw_dataObject (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_urlObject

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_indexObject



11
12
13
# File 'lib/expedia_api/entities/package.rb', line 11

def flight_index
  raw_data[:FlightReferenceIndex].to_i
end

#hotel_indexObject



15
16
17
# File 'lib/expedia_api/entities/package.rb', line 15

def hotel_index
  raw_data[:HotelReferenceIndex].to_i
end

#priceObject

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

#savingsObject

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