Module: Mapper
- Defined in:
- lib/mapper.rb,
lib/mapper/reso.rb
Defined Under Namespace
Modules: Reso
Constant Summary collapse
- RESO_LISTING_ATTRIBUTES =
%w( address alternate_prices appliances architecture_style architecture_style_description bathrooms bedrooms brokerage builder building_unit_count condo_floor_num cooling_systems county currency_code directions disclaimer disclose_address elevation expenses exterior_types floor_coverings foreclosure_status franchise full_bathrooms geocode_options half_bathrooms has_attic has_barbecue_area has_basement has_ceiling_fan has_deck has_disabled_access has_dock has_doorman has_double_pane_windows has_elevator has_fireplace has_garden has_gated_entry has_greenhouse has_hot_tub_spa has_intercom has_jetted_bath_tub has_lawn has_mother_in_law has_patio has_pond has_pool has_porch has_rv_parking has_sauna has_security_system has_skylight has_sports_court has_sprinkler_system has_vaulted_ceiling has_wet_bar heating_fuels heating_systems import is_cable_ready is_new_construction is_waterfront is_wired latitude lead_routing_email legal_description list_price list_price_low listing_category listing_date listing_description listing_provider listing_status listing_title listing_url living_area living_area_unit longitude lot_size mls_number multiple_listing_service modification_timestamp neighborhoods num_floors num_parking_spaces office one_quarter_bathrooms open_houses parcel_info participants permit_address_on_internet photos property_sub_type property_sub_type_description property_type property_type_description roof_types room_count rooms taxes three_quarter_bathrooms videos view_types virtual_tours vow_address_display vow_automated_valuation_display vow_consumer_comment year_built year_updated )
Class Method Summary collapse
- .address_types(item_name) ⇒ Object
- .appliances(item_name) ⇒ Object
- .architecture_styles(item_name) ⇒ Object
- .area_units(item_name) ⇒ Object
- .cooling_systems(item_name) ⇒ Object
- .currency_periods(item_name) ⇒ Object
- .expense_categories(item_name) ⇒ Object
- .exterior_types(item_name) ⇒ Object
- .fetch_enumeration(class_name, item_name) ⇒ Object
- .floor_coverings(item_name) ⇒ Object
- .foreclosure_statuses(item_name) ⇒ Object
- .gender(item_name) ⇒ Object
- .get_boolean_value(queued_listing, elements) ⇒ Object
- .get_enums(queued_listing, elements) ⇒ Object
- .get_repeaters(queued_listing, elements) ⇒ Object
- .get_simple_value(queued_listing, element) ⇒ Object
- .get_subvalue(queued_listing, element, child_elements) ⇒ Object
- .get_value(queued_listing, elements) ⇒ Object
- .heating_fuels(item_name) ⇒ Object
- .heating_systems(item_name) ⇒ Object
- .home_features(item_name) ⇒ Object
- .import_formats(item_name) ⇒ Object
- .license_categories(item_name) ⇒ Object
- .listing_categories(item_name) ⇒ Object
- .listing_statuses(item_name) ⇒ Object
- .parkings(item_name) ⇒ Object
- .participant_roles(item_name) ⇒ Object
- .property_sub_types(item_name) ⇒ Object
- .property_types(item_name) ⇒ Object
- .roof_types(item_name) ⇒ Object
- .room_categories(item_name) ⇒ Object
- .school_categories(item_name) ⇒ Object
- .source_provider_categories(item_name) ⇒ Object
- .unique_identifier(queued_listing) ⇒ Object
- .view_types(item_name) ⇒ Object
Class Method Details
.address_types(item_name) ⇒ Object
121 122 123 |
# File 'lib/mapper.rb', line 121 def self.address_types item_name fetch_enumeration 'AddressType', item_name end |
.appliances(item_name) ⇒ Object
125 126 127 |
# File 'lib/mapper.rb', line 125 def self.appliances item_name fetch_enumeration 'Appliance', item_name end |
.architecture_styles(item_name) ⇒ Object
129 130 131 |
# File 'lib/mapper.rb', line 129 def self.architecture_styles item_name fetch_enumeration 'ArchitectureStyle', item_name end |
.area_units(item_name) ⇒ Object
133 134 135 |
# File 'lib/mapper.rb', line 133 def self.area_units item_name fetch_enumeration 'AreaUnit', item_name end |
.cooling_systems(item_name) ⇒ Object
137 138 139 |
# File 'lib/mapper.rb', line 137 def self.cooling_systems item_name fetch_enumeration 'CoolingSystem', item_name end |
.currency_periods(item_name) ⇒ Object
141 142 143 |
# File 'lib/mapper.rb', line 141 def self.currency_periods item_name fetch_enumeration 'CurrencyPeriod', item_name end |
.expense_categories(item_name) ⇒ Object
145 146 147 |
# File 'lib/mapper.rb', line 145 def self.expense_categories item_name fetch_enumeration 'ExpenseCategory', item_name end |
.exterior_types(item_name) ⇒ Object
149 150 151 |
# File 'lib/mapper.rb', line 149 def self.exterior_types item_name fetch_enumeration 'ExteriorType', item_name end |
.fetch_enumeration(class_name, item_name) ⇒ Object
115 116 117 118 119 |
# File 'lib/mapper.rb', line 115 def self.fetch_enumeration class_name, item_name Rails.cache.fetch([class_name, item_name], expires_in: 1.hours) do class_name.constantize.find_by(name: item_name) end end |
.floor_coverings(item_name) ⇒ Object
153 154 155 |
# File 'lib/mapper.rb', line 153 def self.floor_coverings item_name fetch_enumeration 'FloorCovering', item_name end |
.foreclosure_statuses(item_name) ⇒ Object
157 158 159 |
# File 'lib/mapper.rb', line 157 def self.foreclosure_statuses item_name fetch_enumeration 'ForeclosureStatus', item_name end |
.gender(item_name) ⇒ Object
161 162 163 |
# File 'lib/mapper.rb', line 161 def self.gender item_name fetch_enumeration 'Gender', item_name end |
.get_boolean_value(queued_listing, elements) ⇒ Object
233 234 235 |
# File 'lib/mapper.rb', line 233 def self.get_boolean_value queued_listing, elements (result = Mapper::get_value(queued_listing, elements)) ? result.to_s.to_bool : nil end |
.get_enums(queued_listing, elements) ⇒ Object
267 268 269 270 271 272 |
# File 'lib/mapper.rb', line 267 def self.get_enums queued_listing, elements if (result = get_repeaters(queued_listing, elements)) enums = result.map{|name| Mapper.send(elements.last.tableize, name)} end enums ? enums.compact : nil end |
.get_repeaters(queued_listing, elements) ⇒ Object
259 260 261 262 263 264 265 |
# File 'lib/mapper.rb', line 259 def self.get_repeaters queued_listing, elements if (value = Mapper::get_value(queued_listing, elements[0..-2])) (result = value.drilldown(elements.last)) ? (result.is_a?(Array) ? result : [result]) : nil else return [] end end |
.get_simple_value(queued_listing, element) ⇒ Object
245 246 247 248 249 |
# File 'lib/mapper.rb', line 245 def self.get_simple_value queued_listing, element if (value = queued_listing.listing_data[element]) value.unwrap_attribute end end |
.get_subvalue(queued_listing, element, child_elements) ⇒ Object
251 252 253 254 255 256 257 |
# File 'lib/mapper.rb', line 251 def self.get_subvalue queued_listing, element, child_elements if (value = get_simple_value(queued_listing, element)) if (subvalue = child_elements.inject(value){|v, e| v[e] ? v[e] : Hash.new }) subvalue.present? ? subvalue.unwrap_attribute : nil end end end |
.get_value(queued_listing, elements) ⇒ Object
237 238 239 240 241 242 243 |
# File 'lib/mapper.rb', line 237 def self.get_value queued_listing, elements if elements.count.eql?(1) get_simple_value(queued_listing, elements.first) else get_subvalue(queued_listing, elements.first, elements[1..-1]) end end |
.heating_fuels(item_name) ⇒ Object
165 166 167 |
# File 'lib/mapper.rb', line 165 def self.heating_fuels item_name fetch_enumeration 'HeatingFuel', item_name end |
.heating_systems(item_name) ⇒ Object
169 170 171 |
# File 'lib/mapper.rb', line 169 def self.heating_systems item_name fetch_enumeration 'HeatingSystem', item_name end |
.home_features(item_name) ⇒ Object
173 174 175 |
# File 'lib/mapper.rb', line 173 def self.home_features item_name fetch_enumeration 'HomeFeature', item_name end |
.import_formats(item_name) ⇒ Object
177 178 179 |
# File 'lib/mapper.rb', line 177 def self.import_formats item_name fetch_enumeration 'ImportFormat', item_name end |
.license_categories(item_name) ⇒ Object
181 182 183 |
# File 'lib/mapper.rb', line 181 def self.license_categories item_name fetch_enumeration 'LicenseCategory', item_name end |
.listing_categories(item_name) ⇒ Object
185 186 187 |
# File 'lib/mapper.rb', line 185 def self.listing_categories item_name fetch_enumeration 'ListingCategory', item_name end |
.listing_statuses(item_name) ⇒ Object
189 190 191 |
# File 'lib/mapper.rb', line 189 def self.listing_statuses item_name fetch_enumeration 'ListingStatus', item_name end |
.parkings(item_name) ⇒ Object
193 194 195 |
# File 'lib/mapper.rb', line 193 def self.parkings item_name fetch_enumeration 'Parking', item_name end |
.participant_roles(item_name) ⇒ Object
197 198 199 |
# File 'lib/mapper.rb', line 197 def self.participant_roles item_name fetch_enumeration 'ParticipantRole', item_name end |
.property_sub_types(item_name) ⇒ Object
201 202 203 |
# File 'lib/mapper.rb', line 201 def self.property_sub_types item_name fetch_enumeration 'PropertySubType', item_name end |
.property_types(item_name) ⇒ Object
205 206 207 |
# File 'lib/mapper.rb', line 205 def self.property_types item_name fetch_enumeration 'PropertyType', item_name end |
.roof_types(item_name) ⇒ Object
209 210 211 |
# File 'lib/mapper.rb', line 209 def self.roof_types item_name fetch_enumeration 'RoofType', item_name end |
.room_categories(item_name) ⇒ Object
213 214 215 |
# File 'lib/mapper.rb', line 213 def self.room_categories item_name fetch_enumeration 'RoomCategory', item_name end |
.school_categories(item_name) ⇒ Object
217 218 219 |
# File 'lib/mapper.rb', line 217 def self.school_categories item_name fetch_enumeration 'SchoolCategory', item_name end |
.source_provider_categories(item_name) ⇒ Object
221 222 223 |
# File 'lib/mapper.rb', line 221 def self.source_provider_categories item_name fetch_enumeration 'SourceProviderCategory', item_name end |
.unique_identifier(queued_listing) ⇒ Object
229 230 231 |
# File 'lib/mapper.rb', line 229 def self.unique_identifier queued_listing (result = Mapper::get_value(queued_listing, queued_listing.import.unique_identifier.split(' '))) end |
.view_types(item_name) ⇒ Object
225 226 227 |
# File 'lib/mapper.rb', line 225 def self.view_types item_name fetch_enumeration 'ViewType', item_name end |