Class: Dgrid::API::Place
- Inherits:
-
NamedEntity
- Object
- Entity
- NamedEntity
- Dgrid::API::Place
- Defined in:
- lib/dgrid/api/place.rb
Instance Attribute Summary collapse
-
#lat_long ⇒ Object
Returns the value of attribute lat_long.
Attributes inherited from NamedEntity
Attributes inherited from Entity
#description, #id, #workspaces
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options) ⇒ Place
constructor
A new instance of Place.
- #to_hash ⇒ Object
Methods inherited from Entity
#add_entity, #add_workspace, #attach, #connection, #first_workspace, #in_workspace?, #link_to, #new_record?, singular, #type, type
Methods included from SetMembersFromHash
#change_string_keys_to_symbol_keys, #set_members_from_hash, #split_hash
Methods included from Dgrid::ArgumentValidation
Constructor Details
#initialize(options) ⇒ Place
Returns a new instance of Place.
12 13 14 15 16 17 18 19 20 |
# File 'lib/dgrid/api/place.rb', line 12 def initialize() parent_opts, my_opts = split_hash(,[:name, :description]) super(parent_opts) gps_opts, other_opts = split_hash(,[: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 |
Instance Attribute Details
#lat_long ⇒ Object
Returns the value of attribute lat_long.
4 5 6 |
# File 'lib/dgrid/api/place.rb', line 4 def lat_long @lat_long end |
Class Method Details
.db_fields ⇒ Object
23 24 25 |
# File 'lib/dgrid/api/place.rb', line 23 def self.db_fields %w(id name description latitude longitude elevation) end |
.pluralized ⇒ Object
27 28 29 |
# File 'lib/dgrid/api/place.rb', line 27 def self.pluralized 'places' end |
Instance Method Details
#to_hash ⇒ Object
31 32 33 34 35 36 37 |
# 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 |