Class: Broutes::GeoPoint

Inherits:
Object
  • Object
show all
Defined in:
lib/broutes/geo_point.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ GeoPoint

Returns a new instance of GeoPoint.



8
9
10
# File 'lib/broutes/geo_point.rb', line 8

def initialize(args={})
  args.each_pair do |key, value| send("#{key}=", value) if respond_to?("#{key}=") end
end

Instance Attribute Details

#cadenceObject

Returns the value of attribute cadence.



5
6
7
# File 'lib/broutes/geo_point.rb', line 5

def cadence
  @cadence
end

#distanceObject

Returns the value of attribute distance.



5
6
7
# File 'lib/broutes/geo_point.rb', line 5

def distance
  @distance
end

#elevationObject

Returns the value of attribute elevation.



5
6
7
# File 'lib/broutes/geo_point.rb', line 5

def elevation
  @elevation
end

#heart_rateObject

Returns the value of attribute heart_rate.



5
6
7
# File 'lib/broutes/geo_point.rb', line 5

def heart_rate
  @heart_rate
end

#latObject

Returns the value of attribute lat.



5
6
7
# File 'lib/broutes/geo_point.rb', line 5

def lat
  @lat
end

#lonObject

Returns the value of attribute lon.



5
6
7
# File 'lib/broutes/geo_point.rb', line 5

def lon
  @lon
end

#powerObject

Returns the value of attribute power.



5
6
7
# File 'lib/broutes/geo_point.rb', line 5

def power
  @power
end

#speedObject

Returns the value of attribute speed.



5
6
7
# File 'lib/broutes/geo_point.rb', line 5

def speed
  @speed
end

#temperatureObject

Returns the value of attribute temperature.



5
6
7
# File 'lib/broutes/geo_point.rb', line 5

def temperature
  @temperature
end

#timeObject

Returns the value of attribute time.



6
7
8
# File 'lib/broutes/geo_point.rb', line 6

def time
  @time
end

Class Method Details

.from_hash(h) ⇒ Object



12
13
14
# File 'lib/broutes/geo_point.rb', line 12

def self.from_hash(h)
  GeoPoint.new(h)
end

Instance Method Details

#==(other) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/broutes/geo_point.rb', line 28

def ==(other)
  lat == other.lat &&
  lon == other.lon &&
  elevation == other.elevation &&
  distance == other.distance &&
  time == other.time &&
  heart_rate == other.heart_rate &&
  power == other.power &&
  speed == other.speed &&
  cadence == other.cadence &&
  temperature == other.temperature
end

#has_location?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/broutes/geo_point.rb', line 16

def has_location?
  lat && lon
end

#to_hashObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/broutes/geo_point.rb', line 41

def to_hash
  h = {}
  h['lat'] = lat if lat
  h['lon'] = lon if lon
  h['elevation'] = elevation if elevation
  h['distance'] = distance if distance
  h['time'] = time if time
  h['heart_rate'] = heart_rate if heart_rate
  h['power'] = power if power
  h['speed'] = speed if speed
  h['cadence'] = cadence if cadence
  h['temperature'] = temperature if temperature
  h
end