Class: Geonames::Models::City
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Geonames::Models::City
- Defined in:
- lib/geonames_local/models/postgis.rb
Overview
module Postgis
Instance Attribute Summary collapse
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
-
#z ⇒ Object
Returns the value of attribute z.
Instance Method Summary collapse
-
#abbr ⇒ Object
validates_uniqueness_of :name, :scope => :region_id.
- #geom=(val) ⇒ Object
-
#validation ⇒ Object
Instantiate self.geom as a Point.
Instance Attribute Details
#x ⇒ Object
Returns the value of attribute x.
6 7 8 |
# File 'lib/geonames_local/models/postgis.rb', line 6 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
6 7 8 |
# File 'lib/geonames_local/models/postgis.rb', line 6 def y @y end |
#z ⇒ Object
Returns the value of attribute z.
6 7 8 |
# File 'lib/geonames_local/models/postgis.rb', line 6 def z @z end |
Instance Method Details
#abbr ⇒ Object
validates_uniqueness_of :name, :scope => :region_id
15 16 17 |
# File 'lib/geonames_local/models/postgis.rb', line 15 def abbr region.try(:abbr) || nation.abbr end |
#geom=(val) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/geonames_local/models/postgis.rb', line 19 def geom=(val) self[:geom] = case val when Array then Point.xy(*val) else val end end |
#validation ⇒ Object
Instantiate self.geom as a Point
27 28 29 30 31 32 |
# File 'lib/geonames_local/models/postgis.rb', line 27 def validation self.nation ||= region.nation unless !@x || !@y || @x == '' || @y == '' self.geom = Point.from_x_y(@x.to_f, @y.to_f) end end |