Class: Address
- Inherits:
-
Object
- Object
- Address
- Includes:
- ActiveModel::Validations, GeoKit::Geocoders
- Defined in:
- app/models/address.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
Attribute ==========================================================.
-
#area_id ⇒ Object
Attribute ==========================================================.
-
#city ⇒ Object
Attribute ==========================================================.
-
#lat ⇒ Object
Returns the value of attribute lat.
-
#lng ⇒ Object
Returns the value of attribute lng.
-
#location ⇒ Object
Returns the value of attribute location.
-
#state ⇒ Object
Attribute ==========================================================.
Instance Method Summary collapse
- #closest_regions ⇒ Object
- #full ⇒ Object
-
#initialize(params = {}) ⇒ Address
constructor
Instance Methods =====================================================.
- #to_key ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Address
Instance Methods =====================================================
21 22 23 24 25 26 27 |
# File 'app/models/address.rb', line 21 def initialize(params = {}) if params @address = params[:address] @city = params[:city] @state = params[:state] end end |
Instance Attribute Details
#address ⇒ Object
Attribute ==========================================================
11 12 13 |
# File 'app/models/address.rb', line 11 def address @address end |
#area_id ⇒ Object
Attribute ==========================================================
11 12 13 |
# File 'app/models/address.rb', line 11 def area_id @area_id end |
#city ⇒ Object
Attribute ==========================================================
11 12 13 |
# File 'app/models/address.rb', line 11 def city @city end |
#lat ⇒ Object
Returns the value of attribute lat.
12 13 14 |
# File 'app/models/address.rb', line 12 def lat @lat end |
#lng ⇒ Object
Returns the value of attribute lng.
12 13 14 |
# File 'app/models/address.rb', line 12 def lng @lng end |
#location ⇒ Object
Returns the value of attribute location.
12 13 14 |
# File 'app/models/address.rb', line 12 def location @location end |
#state ⇒ Object
Attribute ==========================================================
11 12 13 |
# File 'app/models/address.rb', line 11 def state @state end |
Instance Method Details
#closest_regions ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'app/models/address.rb', line 35 def closest_regions location = self.geolocate if location.all.length > 1 || location.street_address.nil? [] else point = Point.new() point.set_x_y(self.lat, self.lng) Area.closest_from(point, 400) end end |
#full ⇒ Object
31 32 33 |
# File 'app/models/address.rb', line 31 def full [self.address, self.city, self.state].join(', ') end |
#to_key ⇒ Object
29 |
# File 'app/models/address.rb', line 29 def to_key; end |