class Geonames::Models::City
module Postgis
Attributes
x[RW]
y[RW]
z[RW]
Public Instance Methods
abbr()
click to toggle source
validates_uniqueness_of :name, :scope => :region_id
# File lib/geonames_local/models/postgis.rb, line 15 def abbr region.try(:abbr) || nation.abbr end
geom=(val)
click to toggle source
# 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()
click to toggle source
Instantiate self.geom as a Point
# 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