class Dgrid::API::Place
Attributes
lat_long[RW]
Public Class Methods
db_fields()
click to toggle source
# File lib/dgrid/api/place.rb, line 23 def self.db_fields %w(id name description latitude longitude elevation) end
new(options)
click to toggle source
Calls superclass method
Dgrid::API::NamedEntity::new
# File lib/dgrid/api/place.rb, line 12 def initialize(options) parent_opts, my_opts = split_hash(options,[:name, :description]) super(parent_opts) gps_opts, other_opts = split_hash(options,[:latitude, :longitude, :elevation]) set_members_from_hash(other_opts) if !other_opts.include?(:lat_long) && !gps_opts.empty? self.lat_long = coalesce_gps_opts(gps_opts) end end
pluralized()
click to toggle source
# File lib/dgrid/api/place.rb, line 27 def self.pluralized 'places' end
Public Instance Methods
to_hash()
click to toggle source
Calls superclass method
Dgrid::API::NamedEntity#to_hash
# File lib/dgrid/api/place.rb, line 31 def to_hash h = super if lat_long h.merge!({:latitude => lat_long.lat, :longitude => lat_long.long, :elevation => lat_long.elevation}) end h end
Protected Instance Methods
coalesce_gps_opts(gps_opts)
click to toggle source
# File lib/dgrid/api/place.rb, line 40 def coalesce_gps_opts(gps_opts) gps_opts[:elevation] ||= 0 gps_args = [:latitude,:longitude,:elevation].map {|k| gps_opts[k]} GPSCoordinates.new(*gps_args) end