Class: Suitcase::Hotel
- Inherits:
-
Object
- Object
- Suitcase::Hotel
- Defined in:
- lib/suitcase/hotel/hotel.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#airport_code ⇒ Object
Returns the value of attribute airport_code.
-
#city ⇒ Object
Returns the value of attribute city.
-
#confidence_rating ⇒ Object
Returns the value of attribute confidence_rating.
-
#country ⇒ Object
Returns the value of attribute country.
-
#currency_code ⇒ Object
Returns the value of attribute currency_code.
-
#description ⇒ Object
Returns the value of attribute description.
-
#high_rate ⇒ Object
Returns the value of attribute high_rate.
-
#id ⇒ Object
Returns the value of attribute id.
-
#latitude ⇒ Object
Returns the value of attribute latitude.
-
#longitude ⇒ Object
Returns the value of attribute longitude.
-
#low_rate ⇒ Object
Returns the value of attribute low_rate.
-
#name ⇒ Object
Returns the value of attribute name.
-
#postal_code ⇒ Object
Returns the value of attribute postal_code.
-
#rating ⇒ Object
Returns the value of attribute rating.
-
#tripadvisor_rating ⇒ Object
Returns the value of attribute tripadvisor_rating.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
8 9 10 |
# File 'lib/suitcase/hotel/hotel.rb', line 8 def address @address end |
#airport_code ⇒ Object
Returns the value of attribute airport_code.
8 9 10 |
# File 'lib/suitcase/hotel/hotel.rb', line 8 def airport_code @airport_code end |
#city ⇒ Object
Returns the value of attribute city.
8 9 10 |
# File 'lib/suitcase/hotel/hotel.rb', line 8 def city @city end |
#confidence_rating ⇒ Object
Returns the value of attribute confidence_rating.
8 9 10 |
# File 'lib/suitcase/hotel/hotel.rb', line 8 def @confidence_rating end |
#country ⇒ Object
Returns the value of attribute country.
8 9 10 |
# File 'lib/suitcase/hotel/hotel.rb', line 8 def country @country end |
#currency_code ⇒ Object
Returns the value of attribute currency_code.
8 9 10 |
# File 'lib/suitcase/hotel/hotel.rb', line 8 def currency_code @currency_code end |
#description ⇒ Object
Returns the value of attribute description.
8 9 10 |
# File 'lib/suitcase/hotel/hotel.rb', line 8 def description @description end |
#high_rate ⇒ Object
Returns the value of attribute high_rate.
8 9 10 |
# File 'lib/suitcase/hotel/hotel.rb', line 8 def high_rate @high_rate end |
#id ⇒ Object
Returns the value of attribute id.
8 9 10 |
# File 'lib/suitcase/hotel/hotel.rb', line 8 def id @id end |
#latitude ⇒ Object
Returns the value of attribute latitude.
8 9 10 |
# File 'lib/suitcase/hotel/hotel.rb', line 8 def latitude @latitude end |
#longitude ⇒ Object
Returns the value of attribute longitude.
8 9 10 |
# File 'lib/suitcase/hotel/hotel.rb', line 8 def longitude @longitude end |
#low_rate ⇒ Object
Returns the value of attribute low_rate.
8 9 10 |
# File 'lib/suitcase/hotel/hotel.rb', line 8 def low_rate @low_rate end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/suitcase/hotel/hotel.rb', line 8 def name @name end |
#postal_code ⇒ Object
Returns the value of attribute postal_code.
8 9 10 |
# File 'lib/suitcase/hotel/hotel.rb', line 8 def postal_code @postal_code end |
#rating ⇒ Object
Returns the value of attribute rating.
8 9 10 |
# File 'lib/suitcase/hotel/hotel.rb', line 8 def @rating end |
#tripadvisor_rating ⇒ Object
Returns the value of attribute tripadvisor_rating.
8 9 10 |
# File 'lib/suitcase/hotel/hotel.rb', line 8 def @tripadvisor_rating end |
Class Method Details
.find(hash) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/suitcase/hotel/hotel.rb', line 10 def self.find(hash) hotels = [] json = JSON.parse Net::HTTP.get_response(URI.parse(URI.escape("http://api.ean.com/ean-services/rs/hotel/v3/list?apiKey=#{Suitcase::Hotel::API_KEY}&city=#{hash[:near]}&numberOfResults=#{hash[:results]}"))).body if json["HotelListResponse"]["HotelList"] json["HotelListResponse"]["HotelList"]["HotelSummary"].each do |hotel_data| h = Hotel.new h.id = hotel_data["hotelId"] h.name = hotel_data["name"] h.address = hotel_data["address1"] h.city = hotel_data["city"] h.postal_code = hotel_data["postalCode"] h.country = COUNTRY_CODES[hotel_data["countryCode"]] h.airport_code = hotel_data["airportCode"] h. = hotel_data["hotelRating"] h. = hotel_data["confidenceRating"] h. = hotel_data["tripAdvisorRating"] h.currency_code = hotel_data["rateCurrencyCode"] h.latitude = hotel_data["latitude"] h.longitude = hotel_data["longitude"] h.high_rate = hotel_data["highRate"] h.low_rate = hotel_data["lowRate"] hotels.push(h) end hotels[0..hash[:results]-1] else if json["HotelListResponse"]["EanWsError"] raise "An error occured. Check data." end end end |
Instance Method Details
#complete_address ⇒ Object
45 46 47 |
# File 'lib/suitcase/hotel/hotel.rb', line 45 def complete_address address + " " + city + ", " + country + " " + postal_code end |
#geolocation ⇒ Object
41 42 43 |
# File 'lib/suitcase/hotel/hotel.rb', line 41 def geolocation latitude + ", " + longitude end |