Class: Strava::Club
Overview
Clubs represent groups of athletes on Strava. They can be public or private. Clubs have both summary and detailed representations.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #activities(per_page: nil, page: nil, before: nil) ⇒ Object
- #admins(per_page: nil, page: nil) ⇒ Object
- #announcements ⇒ Object
- #get_details ⇒ Object
- #group_events(per_page: nil, page: nil, before: nil) ⇒ Object
-
#join ⇒ Object
"active"=>false.
-
#leave ⇒ Object
"active"=>true, "membership"=>"member".
- #members(per_page: nil, page: nil) ⇒ Object
-
#update(data, **opts) ⇒ self
Update an existing club.
Methods inherited from Base
#detailed?, #initialize, #resource_state, resource_states, #summary?
Constructor Details
This class inherits a constructor from Strava::Base
Instance Method Details
#activities(per_page: nil, page: nil, before: nil) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/strava/club.rb', line 35 def activities(per_page: nil, page: nil, before: nil) if page || per_page || before get_activities(per_page: per_page, page: page, before: before) else get_activities if @activities.empty? @activities.values end end |
#admins(per_page: nil, page: nil) ⇒ Object
68 69 70 71 72 73 74 75 |
# File 'lib/strava/club.rb', line 68 def admins(per_page: nil, page: nil) if page || per_page get_admins(per_page: per_page, page: page) else get_admins if @admins.empty? @admins end end |
#announcements ⇒ Object
53 54 55 56 |
# File 'lib/strava/club.rb', line 53 def announcements get_announcements if @announcements.empty? @announcements end |
#get_details ⇒ Object
87 88 89 90 91 |
# File 'lib/strava/club.rb', line 87 def get_details return self if detailed? res = client.get(path_base).to_h update(res) end |
#group_events(per_page: nil, page: nil, before: nil) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/strava/club.rb', line 44 def group_events(per_page: nil, page: nil, before: nil) if page || per_page || before get_group_events(per_page: per_page, page: page, before: before) else get_group_events if @group_events.empty? @group_events.values end end |
#join ⇒ Object
"active"=>false
78 79 80 |
# File 'lib/strava/club.rb', line 78 def join res = client.post(path_join).to_h end |
#leave ⇒ Object
"active"=>true, "membership"=>"member"
83 84 85 |
# File 'lib/strava/club.rb', line 83 def leave res = client.post(path_leave).to_h end |
#members(per_page: nil, page: nil) ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/strava/club.rb', line 58 def members(per_page: nil, page: nil) if page || per_page get_members(per_page: per_page, page: page) else get_members if @members.empty? || !@members_fetched @members_fetched = true @members.values end end |
#update(data, **opts) ⇒ self
Update an existing club. Used by other methods in the gem. Should not be used directly.
27 28 29 30 31 32 33 |
# File 'lib/strava/club.rb', line 27 def update(data, **opts) @response = data @id = data["id"] @resource_state = data['resource_state'] self end |