Class: StravaApi::Segment

Inherits:
HashBasedStore show all
Defined in:
lib/strava-api/segment.rb

Overview

"name":"Panoramic to Pan Toll",
"id":156,
"climbCategory":"4",
"elevationGain":151.728,
"elevationHigh":458.206,
"elevationLow":304.395,
"distance":2378.34,
"averageGrade":6.50757

Constant Summary collapse

ATTRIBUTE_MAP =
{
  'name' => :name,
  'id' => :id,
  "climbCategory" => :climb_category,
  "elevationGain" => :elevation_gain,
  "elevationHigh" => :elevation_high,
  "elevationLow" => :elevation_low,
  "distance" => :distance,
  "averageGrade" => :average_grade
}

Instance Method Summary collapse

Methods inherited from HashBasedStore

#[], #id, #merge, #method_missing, #to_s

Constructor Details

#initialize(connection, options = {}) ⇒ Segment

Returns a new instance of Segment.



23
24
25
# File 'lib/strava-api/segment.rb', line 23

def initialize(connection, options = {})
  super(connection, ATTRIBUTE_MAP, {}, options)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class StravaApi::HashBasedStore

Instance Method Details

#efforts(options = {}) ⇒ Object



32
33
34
# File 'lib/strava-api/segment.rb', line 32

def efforts(options = {})
  @connection.segment_efforts(self.id, options)
end

#showObject



27
28
29
30
# File 'lib/strava-api/segment.rb', line 27

def show
  self.merge(@connection.segment_show(self.id))
  self
end