Class: Strava::LeaderboardEntry

Inherits:
Base
  • Object
show all
Defined in:
lib/strava/leaderboard_entry.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#client, #id, #response

Instance Method Summary collapse

Methods inherited from Base

#detailed?, #initialize, #resource_state, resource_states, #summary?

Constructor Details

This class inherits a constructor from Strava::Base

Instance Attribute Details

#rankObject (readonly)

Class to represent Strava Activity https://strava.github.io/api/v3/activities/



5
6
7
# File 'lib/strava/leaderboard_entry.rb', line 5

def rank
  @rank
end

Instance Method Details

#activityObject



15
16
17
# File 'lib/strava/leaderboard_entry.rb', line 15

def activity
  @activity ||= Activity.new({'id' => @activity_id}, client: @client)
end

#athleteObject



11
12
13
# File 'lib/strava/leaderboard_entry.rb', line 11

def athlete
  @athlete ||= Athlete.new({'id' => @athlete_id}, client: @client)
end

#effortObject



19
20
21
# File 'lib/strava/leaderboard_entry.rb', line 19

def effort
  @effort ||= SegmentEffort.new({'id' => @effort_id}, client: @client)
end

#set_ivarsObject



7
8
9
# File 'lib/strava/leaderboard_entry.rb', line 7

def set_ivars
  @entries = {}
end

#update(data, **opts) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/strava/leaderboard_entry.rb', line 23

def update(data, **opts)
  @response = data

  @athlete_name     = data["athlete_name"]      # => "Jim Whimpey",
  @athlete_id       = data["athlete_id"]        # => 123529,
  @athlete_gender   = data["athlete_gender"]    # => "M",
  @average_hr       = data["average_hr"]        # => 190.5,
  @average_watts    = data["average_watts"]     # => 460.8,
  @distance         = data["distance"]          # => 2659.89,
  @elapsed_time     = data["elapsed_time"]      # => 360,
  @moving_time      = data["moving_time"]       # => 360,
  @start_date       = data["start_date"]        # => "2013-03-29T13:49:35Z",
  @start_date_local = data["start_date_local"]  # => "2013-03-29T06:49:35Z",
  @activity_id      = data["activity_id"]       # => 46320211,
  @effort_id        = data["effort_id"]         # => 801006623,
  @rank             = data["rank"]              # => 1,
  @athlete_profile  = data["athlete_profile"]   # => "http://pics.com/227615/large.jpg"

end