Class: TodaysPlan::Activity
- Inherits:
-
Object
- Object
- TodaysPlan::Activity
- Defined in:
- lib/todays_plan/activity.rb,
lib/todays_plan/activity/power.rb,
lib/todays_plan/activity/summary.rb,
lib/todays_plan/activity/heartrate.rb
Overview
Uses the TodaysPlan API for workouts and athlete information
Defined Under Namespace
Classes: Heartrate, Power, Summary
Instance Attribute Summary collapse
-
#activity ⇒ Object
readonly
Returns the value of attribute activity.
-
#activity_id ⇒ Object
readonly
Returns the value of attribute activity_id.
-
#athlete_id ⇒ Object
readonly
Returns the value of attribute athlete_id.
-
#completed_time ⇒ Object
readonly
Returns the value of attribute completed_time.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#intensity_factor ⇒ Object
readonly
Returns the value of attribute intensity_factor.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#scheduled_time ⇒ Object
readonly
Returns the value of attribute scheduled_time.
-
#scheduled_tscorepwr ⇒ Object
readonly
Returns the value of attribute scheduled_tscorepwr.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#ts ⇒ Object
readonly
Returns the value of attribute ts.
-
#tscorepwr ⇒ Object
readonly
Returns the value of attribute tscorepwr.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
-
.all(payload, offset = 0, total = 100, client: nil) ⇒ Object
- Find all coaches athletes workouts
payload
- they payload to send to in json format
offset
- record count to start out
total
- number of records to return
client
-
the authenticated client payload example: { “criteria”: { “fromTs”: 1451566800000, “toTs”: 1496239200000, “isNull”: [ “fileId” ], “excludeWorkouts”: [ “rest” ] }, “fields”: [ “scheduled.name”, “scheduled.day”, “workout”, “state”, “reason” ], “opts”: 1 }.
- number of records to return
- record count to start out
- they payload to send to in json format
- Find all coaches athletes workouts
-
.find(id, activity = "workouts", client = nil) ⇒ Object
Find the activity
id
: the activity idactivity
: the type of activity to view, workouts or files.
Instance Method Summary collapse
-
#initialize(fields) ⇒ Activity
constructor
A new instance of Activity.
Constructor Details
#initialize(fields) ⇒ Activity
Returns a new instance of Activity.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/todays_plan/activity.rb', line 21 def initialize(fields) @id = fields['id'].to_i @activity_id = fields['activityId'].to_i @athlete_id = fields['user']['id'].to_i @name = fields['name'] @state = fields['state'] @ts = fields['ts'].to_i @type = fields['type'] @completed_time = find_completed_time(fields) @scheduled_time = find_planned_time(fields) @description = fields.has_key?('scheduled')? fields['scheduled']["preDescr"] : nil @tscorepwr = find_completed_tscore(fields) @scheduled_tscorepwr = find_planned_tscore(fields) @intensity_factor = fields['iff'] @activity = fields['activity'] end |
Instance Attribute Details
#activity ⇒ Object (readonly)
Returns the value of attribute activity.
19 20 21 |
# File 'lib/todays_plan/activity.rb', line 19 def activity @activity end |
#activity_id ⇒ Object (readonly)
Returns the value of attribute activity_id.
7 8 9 |
# File 'lib/todays_plan/activity.rb', line 7 def activity_id @activity_id end |
#athlete_id ⇒ Object (readonly)
Returns the value of attribute athlete_id.
8 9 10 |
# File 'lib/todays_plan/activity.rb', line 8 def athlete_id @athlete_id end |
#completed_time ⇒ Object (readonly)
Returns the value of attribute completed_time.
13 14 15 |
# File 'lib/todays_plan/activity.rb', line 13 def completed_time @completed_time end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
15 16 17 |
# File 'lib/todays_plan/activity.rb', line 15 def description @description end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/todays_plan/activity.rb', line 6 def id @id end |
#intensity_factor ⇒ Object (readonly)
Returns the value of attribute intensity_factor.
18 19 20 |
# File 'lib/todays_plan/activity.rb', line 18 def intensity_factor @intensity_factor end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/todays_plan/activity.rb', line 9 def name @name end |
#scheduled_time ⇒ Object (readonly)
Returns the value of attribute scheduled_time.
14 15 16 |
# File 'lib/todays_plan/activity.rb', line 14 def scheduled_time @scheduled_time end |
#scheduled_tscorepwr ⇒ Object (readonly)
Returns the value of attribute scheduled_tscorepwr.
17 18 19 |
# File 'lib/todays_plan/activity.rb', line 17 def scheduled_tscorepwr @scheduled_tscorepwr end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
10 11 12 |
# File 'lib/todays_plan/activity.rb', line 10 def state @state end |
#ts ⇒ Object (readonly)
Returns the value of attribute ts.
11 12 13 |
# File 'lib/todays_plan/activity.rb', line 11 def ts @ts end |
#tscorepwr ⇒ Object (readonly)
Returns the value of attribute tscorepwr.
16 17 18 |
# File 'lib/todays_plan/activity.rb', line 16 def tscorepwr @tscorepwr end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
12 13 14 |
# File 'lib/todays_plan/activity.rb', line 12 def type @type end |
Class Method Details
.all(payload, offset = 0, total = 100, client: nil) ⇒ Object
Find all coaches athletes workouts
payload
-
they payload to send to in json format
offset
-
record count to start out
total
-
number of records to return
client
-
the authenticated client
payload example:
{
"criteria": {
"fromTs": 1451566800000,
"toTs": 1496239200000,
"isNull": [
"fileId"
],
"excludeWorkouts": [
"rest"
]
},
"fields": [
"scheduled.name",
"scheduled.day",
"workout",
“state”,
“reason”
],
"opts": 1
}
73 74 75 76 77 78 |
# File 'lib/todays_plan/activity.rb', line 73 def self.all(payload,offset = 0, total = 100, client: nil) Connector.new("/users/activities/search/#{offset}/#{total}/", client). post(payload)['result']['results'].map do |data| new(data) end end |
.find(id, activity = "workouts", client = nil) ⇒ Object
Find the activity id
: the activity id activity
: the type of activity to view, workouts or files. Defaults to workouts
client
-
the authenticated client
42 43 44 45 |
# File 'lib/todays_plan/activity.rb', line 42 def self.find(id, activity="workouts", client = nil) fields = {"activityId"=>id} new(fields.merge(Connector.new("/plans/#{activity}/detailed/#{id}",client).get())) end |