Class: MLS::Address
Defined Under Namespace
Classes: Parser
Instance Attribute Summary collapse
-
#listing_types ⇒ Object
Returns the value of attribute listing_types.
-
#listings ⇒ Object
Returns the value of attribute listings.
-
#photos ⇒ Object
Returns the value of attribute photos.
-
#videos ⇒ Object
Returns the value of attribute videos.
Attributes inherited from Resource
Class Method Summary collapse
-
.all(options = {}) ⇒ Object
currently supported options are :include, :where, :limit, :offset.
-
.box_cluster(bounds, zoom, where = {}) ⇒ Object
Bounds is passed as ‘n,e,s,w’ or [n, e, s, w].
- .find(id) ⇒ Object
- .query(q) ⇒ Object
Instance Method Summary collapse
- #amenities ⇒ Object
-
#avatar(size = '100x200', protocol = 'http') ⇒ Object
should include an optional use address or no_image image.
- #find_listings(space_available, floor, unit) ⇒ Object
- #save ⇒ Object
- #to_hash ⇒ Object
- #to_param ⇒ Object
- #url ⇒ Object
Methods inherited from Resource
#==, #create!, inherited, #initialize, #new_record?, #persisted?, #properties, #properties_excluded_from_comparison, #properties_for_comparison, #save!, #set_default_values, #to_key, #update!, #update_attributes
Constructor Details
This class inherits a constructor from MLS::Resource
Instance Attribute Details
#listing_types ⇒ Object
Returns the value of attribute listing_types.
51 52 53 |
# File 'lib/mls/models/address.rb', line 51 def listing_types @listing_types end |
#listings ⇒ Object
Returns the value of attribute listings.
51 52 53 |
# File 'lib/mls/models/address.rb', line 51 def listings @listings end |
#photos ⇒ Object
Returns the value of attribute photos.
51 52 53 |
# File 'lib/mls/models/address.rb', line 51 def photos @photos end |
#videos ⇒ Object
Returns the value of attribute videos.
51 52 53 |
# File 'lib/mls/models/address.rb', line 51 def videos @videos end |
Class Method Details
.all(options = {}) ⇒ Object
currently supported options are :include, :where, :limit, :offset
136 137 138 139 |
# File 'lib/mls/models/address.rb', line 136 def all(={}) response = MLS.get('/addresses', ) MLS::Address::Parser.parse_collection(response.body) end |
.box_cluster(bounds, zoom, where = {}) ⇒ Object
Bounds is passed as ‘n,e,s,w’ or [n, e, s, w]
126 127 128 |
# File 'lib/mls/models/address.rb', line 126 def box_cluster(bounds, zoom, where={}) MLS.get('/addresses/box_cluster', :bounds => bounds, :zoom => zoom, :where => where) end |
Instance Method Details
#amenities ⇒ Object
108 109 110 |
# File 'lib/mls/models/address.rb', line 108 def amenities MLS.address_amenities end |
#avatar(size = '100x200', protocol = 'http') ⇒ Object
should include an optional use address or no_image image
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/mls/models/address.rb', line 54 def avatar(size='100x200', protocol='http') params = { :size => size, :format => 'png', :sensor => false, :location => [formatted_address], :fov => 120 } if avatar_digest "#{protocol}://#{MLS.asset_host}/photos/#{size}/#{avatar_digest}.jpg" else "#{protocol}://maps.googleapis.com/maps/api/streetview?" + params.map{|k,v| k.to_s + '=' + URI.escape(v.to_s) }.join('&') end end |
#find_listings(space_available, floor, unit) ⇒ Object
112 113 114 115 116 |
# File 'lib/mls/models/address.rb', line 112 def find_listings(space_available, floor, unit) response = MLS.get("/addresses/#{id}/find_listings", :floor => floor, :unit => unit, :space_available => space_available) MLS::Listing::Parser.parse_collection(response.body) end |
#save ⇒ Object
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/mls/models/address.rb', line 70 def save MLS.put("/addresses/#{id}", {:address => to_hash}, 400) do |response, code| if code == 200 || code == 400 MLS::Address::Parser.update(self, response.body) code == 200 else raise MLS::Exception::UnexpectedResponse, code end end end |
#to_hash ⇒ Object
81 82 83 84 85 86 |
# File 'lib/mls/models/address.rb', line 81 def to_hash hash = super hash[:photo_ids] = photos.map(&:id) if photos hash[:videos_attributes] = videos.map(&:to_hash) if videos hash end |
#to_param ⇒ Object
88 89 90 |
# File 'lib/mls/models/address.rb', line 88 def to_param [state, city, "#{street_number} #{street}"].map(&:parameterize).join('/') end |
#url ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/mls/models/address.rb', line 92 def url if defined? Rails case Rails.env when "production" host = "42floors.com" when "staging" host = "staging.42floors.com" when "development","test" host = "spire.dev" end else host = "42floors.com" end "http://#{host}/#{slug}" end |