Class: Nineflats::Place
Instance Attribute Summary collapse
-
#amenities_list ⇒ Object
Returns the value of attribute amenities_list.
-
#bathroom_type ⇒ Object
Returns the value of attribute bathroom_type.
-
#bed_type ⇒ Object
Returns the value of attribute bed_type.
-
#calendar_current_month_url ⇒ Object
Returns the value of attribute calendar_current_month_url.
-
#calendar_next_month_url ⇒ Object
Returns the value of attribute calendar_next_month_url.
-
#category ⇒ Object
Returns the value of attribute category.
-
#charge_per_extra_person ⇒ Object
Returns the value of attribute charge_per_extra_person.
-
#charge_per_extra_person_limit ⇒ Object
Returns the value of attribute charge_per_extra_person_limit.
-
#city ⇒ Object
Returns the value of attribute city.
-
#cleaning_fee ⇒ Object
Returns the value of attribute cleaning_fee.
-
#content_language ⇒ Object
Returns the value of attribute content_language.
-
#country ⇒ Object
Returns the value of attribute country.
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#description ⇒ Object
Returns the value of attribute description.
-
#district ⇒ Object
Returns the value of attribute district.
-
#favorites_count ⇒ Object
Returns the value of attribute favorites_count.
-
#featured_photo_url ⇒ Object
Returns the value of attribute featured_photo_url.
-
#full_url ⇒ Object
Returns the value of attribute full_url.
-
#host ⇒ Object
Returns the value of attribute host.
-
#house_rules ⇒ Object
Returns the value of attribute house_rules.
-
#lat ⇒ Object
Returns the value of attribute lat.
-
#lng ⇒ Object
Returns the value of attribute lng.
-
#maximum_nights ⇒ Object
Returns the value of attribute maximum_nights.
-
#minimum_nights ⇒ Object
Returns the value of attribute minimum_nights.
-
#name ⇒ Object
Returns the value of attribute name.
-
#number_of_bathrooms ⇒ Object
Returns the value of attribute number_of_bathrooms.
-
#number_of_bedrooms ⇒ Object
Returns the value of attribute number_of_bedrooms.
-
#number_of_beds ⇒ Object
Returns the value of attribute number_of_beds.
-
#pets_around ⇒ Object
Returns the value of attribute pets_around.
-
#photos ⇒ Object
Returns the value of attribute photos.
-
#photos_url ⇒ Object
Returns the value of attribute photos_url.
-
#place_type ⇒ Object
Returns the value of attribute place_type.
-
#price ⇒ Object
Returns the value of attribute price.
-
#prices ⇒ Object
Returns the value of attribute prices.
-
#prices_url ⇒ Object
Returns the value of attribute prices_url.
-
#reviews ⇒ Object
Returns the value of attribute reviews.
-
#reviews_url ⇒ Object
Returns the value of attribute reviews_url.
-
#self_url ⇒ Object
Returns the value of attribute self_url.
-
#size ⇒ Object
Returns the value of attribute size.
-
#slug ⇒ Object
Returns the value of attribute slug.
-
#zipcode ⇒ Object
Returns the value of attribute zipcode.
Class Method Summary collapse
- .api_call(slug, lang) ⇒ Object
- .fetch(slug, lang) ⇒ Object
- .search(params = nil) ⇒ Object
- .search_result(search_url) ⇒ Object
Instance Method Summary collapse
- #calendar(year, month) ⇒ Object
-
#initialize(json) ⇒ Place
constructor
A new instance of Place.
Methods inherited from Base
base_url, client_app_key, client_app_key=, object_link
Constructor Details
#initialize(json) ⇒ Place
Returns a new instance of Place.
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/nineflats-api/place.rb', line 14 def initialize(json) place = json.first[1] @name = place["name"] @city = place["city"] @currency = place["currency"] @slug = place["slug"] @zipcode = place["zipcode"] @number_of_beds = place["number_of_beds"] @number_of_bedrooms = place["number_of_bedrooms"] @number_of_bathrooms = place["number_of_bathrooms"] @charge_per_extra_person = place["charge_per_extra_person"] @content_language = place["content_language"] @minimum_nights = place["minimum_nights"] @maximum_nights = place["maximum_nights"] @bed_type = place["bed_type"] @size = place["size"] @house_rules = place["house_rules"] @pets_around = place["pets_around"] @bathroom_type = place["bathroom_type"] @cleaning_fee = place["cleaning_fee"] @charge_per_extra_person_limit = place["charge_per_extra_person_limit"] @favorites_count = place["favorites_count"] @amenities_list = place["amenities_list"] @featured_photo_url = place["featured_photo_url"] @price = place["price"] @country = place["country"] @category = place["category"] @place_type = place["place_type"] @lat = place["lat"] @lng = place["lng"] @district = place["district"] @description = place["description"] @host = User.new({"user" => place["host"]}) @self_url = Nineflats::Base.object_link("self", place["links"]) @full_url = Nineflats::Base.object_link("full", place["links"]) @photos_url = Nineflats::Base.object_link("photos", place["links"]) @prices_url = Nineflats::Base.object_link("prices", place["links"]) @reviews_url = Nineflats::Base.object_link("reviews", place["links"]) @calendar_current_month_url = Nineflats::Base.object_link("calendar: current month", place["links"]) @calendar_next_month_url = Nineflats::Base.object_link("calendar: next month", place["links"]) end |
Instance Attribute Details
#amenities_list ⇒ Object
Returns the value of attribute amenities_list.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def amenities_list @amenities_list end |
#bathroom_type ⇒ Object
Returns the value of attribute bathroom_type.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def bathroom_type @bathroom_type end |
#bed_type ⇒ Object
Returns the value of attribute bed_type.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def bed_type @bed_type end |
#calendar_current_month_url ⇒ Object
Returns the value of attribute calendar_current_month_url.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def calendar_current_month_url @calendar_current_month_url end |
#calendar_next_month_url ⇒ Object
Returns the value of attribute calendar_next_month_url.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def calendar_next_month_url @calendar_next_month_url end |
#category ⇒ Object
Returns the value of attribute category.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def category @category end |
#charge_per_extra_person ⇒ Object
Returns the value of attribute charge_per_extra_person.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def charge_per_extra_person @charge_per_extra_person end |
#charge_per_extra_person_limit ⇒ Object
Returns the value of attribute charge_per_extra_person_limit.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def charge_per_extra_person_limit @charge_per_extra_person_limit end |
#city ⇒ Object
Returns the value of attribute city.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def city @city end |
#cleaning_fee ⇒ Object
Returns the value of attribute cleaning_fee.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def cleaning_fee @cleaning_fee end |
#content_language ⇒ Object
Returns the value of attribute content_language.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def content_language @content_language end |
#country ⇒ Object
Returns the value of attribute country.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def country @country end |
#currency ⇒ Object
Returns the value of attribute currency.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def currency @currency end |
#description ⇒ Object
Returns the value of attribute description.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def description @description end |
#district ⇒ Object
Returns the value of attribute district.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def district @district end |
#favorites_count ⇒ Object
Returns the value of attribute favorites_count.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def favorites_count @favorites_count end |
#featured_photo_url ⇒ Object
Returns the value of attribute featured_photo_url.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def featured_photo_url @featured_photo_url end |
#full_url ⇒ Object
Returns the value of attribute full_url.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def full_url @full_url end |
#host ⇒ Object
Returns the value of attribute host.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def host @host end |
#house_rules ⇒ Object
Returns the value of attribute house_rules.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def house_rules @house_rules end |
#lat ⇒ Object
Returns the value of attribute lat.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def lat @lat end |
#lng ⇒ Object
Returns the value of attribute lng.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def lng @lng end |
#maximum_nights ⇒ Object
Returns the value of attribute maximum_nights.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def maximum_nights @maximum_nights end |
#minimum_nights ⇒ Object
Returns the value of attribute minimum_nights.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def minimum_nights @minimum_nights end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def name @name end |
#number_of_bathrooms ⇒ Object
Returns the value of attribute number_of_bathrooms.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def number_of_bathrooms @number_of_bathrooms end |
#number_of_bedrooms ⇒ Object
Returns the value of attribute number_of_bedrooms.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def number_of_bedrooms @number_of_bedrooms end |
#number_of_beds ⇒ Object
Returns the value of attribute number_of_beds.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def number_of_beds @number_of_beds end |
#pets_around ⇒ Object
Returns the value of attribute pets_around.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def pets_around @pets_around end |
#photos ⇒ Object
Returns the value of attribute photos.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def photos @photos end |
#photos_url ⇒ Object
Returns the value of attribute photos_url.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def photos_url @photos_url end |
#place_type ⇒ Object
Returns the value of attribute place_type.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def place_type @place_type end |
#price ⇒ Object
Returns the value of attribute price.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def price @price end |
#prices ⇒ Object
Returns the value of attribute prices.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def prices @prices end |
#prices_url ⇒ Object
Returns the value of attribute prices_url.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def prices_url @prices_url end |
#reviews ⇒ Object
Returns the value of attribute reviews.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def reviews @reviews end |
#reviews_url ⇒ Object
Returns the value of attribute reviews_url.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def reviews_url @reviews_url end |
#self_url ⇒ Object
Returns the value of attribute self_url.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def self_url @self_url end |
#size ⇒ Object
Returns the value of attribute size.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def size @size end |
#slug ⇒ Object
Returns the value of attribute slug.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def slug @slug end |
#zipcode ⇒ Object
Returns the value of attribute zipcode.
3 4 5 |
# File 'lib/nineflats-api/place.rb', line 3 def zipcode @zipcode end |
Class Method Details
.api_call(slug, lang) ⇒ Object
133 134 135 |
# File 'lib/nineflats-api/place.rb', line 133 def self.api_call(slug, lang) base_url + "/places/#{slug}?client_id=#{Nineflats::Base.client_app_key}&lang=#{lang}" end |
.fetch(slug, lang) ⇒ Object
91 92 93 |
# File 'lib/nineflats-api/place.rb', line 91 def self.fetch(slug, lang) Place.new(Helpers.get_data(Place.api_call(slug, lang))) end |
.search(params = nil) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/nineflats-api/place.rb', line 59 def self.search(params = nil) params ||= {} queries = params.collect do |key, value| "&search[#{key}]=#{value}" end search_url = base_url + "/places?client_id=#{Nineflats::Base.client_app_key}" + queries.join Place.search_result(search_url) end |
.search_result(search_url) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/nineflats-api/place.rb', line 71 def self.search_result(search_url) json = Helpers.get_data(search_url) places = json["places"].collect do |place_json| Place.new(place_json) end result = Nineflats::PaginatedArray.new(places) result.total_entries = json["total_entries"] result.total_pages = json["total_pages"] result.current_page = json["current_page"] result.per_page = json["per_page"] result.self_url = Nineflats::Base.object_link("self", json["links"]) result.full_url = Nineflats::Base.object_link("full", json["links"]) result.next_page_url = Nineflats::Base.object_link("next_page", json["links"]) result end |