Class: Geoptima::LocatableImpl

Inherits:
Object
  • Object
show all
Includes:
Locatable
Defined in:
lib/geoptima/locator.rb

Instance Attribute Summary collapse

Attributes included from Locatable

#location, #next_gps, #next_point, #next_point_gap, #previous_gps, #previous_point, #previous_point_gap

Instance Method Summary collapse

Methods included from Locatable

#closer_than, #set_next_if, #set_previous_if

Constructor Details

#initialize(attributes) ⇒ LocatableImpl

Returns a new instance of LocatableImpl.



98
99
100
101
102
# File 'lib/geoptima/locator.rb', line 98

def initialize(attributes)
  @attributes = Hash[*attributes.map{|k,v| [k.to_s,v]}.flatten]
  @name = @attributes['name']
  @time = @attributes['time']
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



95
96
97
# File 'lib/geoptima/locator.rb', line 95

def attributes
  @attributes
end

#nameObject (readonly)

Returns the value of attribute name.



95
96
97
# File 'lib/geoptima/locator.rb', line 95

def name
  @name
end

#timeObject

Returns the value of attribute time.



96
97
98
# File 'lib/geoptima/locator.rb', line 96

def time
  @time
end

Instance Method Details

#-(other) ⇒ Object



109
110
111
# File 'lib/geoptima/locator.rb', line 109

def -(other)
  (self.time - other.time) * SPERDAY
end

#[](key) ⇒ Object



103
104
105
# File 'lib/geoptima/locator.rb', line 103

def [](key)
  @attributes[key.to_s] || @attributes[key.to_s.gsub(/#{name}\./,'')]
end

#[]=(key, value) ⇒ Object



106
107
108
# File 'lib/geoptima/locator.rb', line 106

def []=(key,value)
  @attributes[key.to_s] = value
end

#to_sObject



112
113
114
# File 'lib/geoptima/locator.rb', line 112

def to_s
  @attributes.inspect
end