Class: Strava::Usage
- Inherits:
-
Object
- Object
- Strava::Usage
- Defined in:
- lib/strava/usage.rb
Overview
Provides data on Strava API limits and usage.
Usage:
ca = Strava::Athlete.current_athlete
usage = ca.client.usage
usage.recent_usage # => 254
usage.daily_usage # => 12536
usage.recent_pct # => 0.423
usage.daily_pct # => 0.417
Instance Attribute Summary collapse
-
#daily_limit ⇒ Object
readonly
Returns the value of attribute daily_limit.
-
#daily_usage ⇒ Object
readonly
Returns the value of attribute daily_usage.
-
#recent_limit ⇒ Object
readonly
Returns the value of attribute recent_limit.
-
#recent_usage ⇒ Object
readonly
Returns the value of attribute recent_usage.
Instance Method Summary collapse
-
#daily_pct ⇒ Float
Percentage of daily limit used.
-
#initialize(limit_str, usage_str) ⇒ Usage
constructor
A new instance of Usage.
-
#recent_pct ⇒ Float
Percentage of recent limit used.
Constructor Details
#initialize(limit_str, usage_str) ⇒ Usage
Returns a new instance of Usage.
17 18 19 20 |
# File 'lib/strava/usage.rb', line 17 def initialize(limit_str, usage_str) @recent_limit, @daily_limit = limit_str.to_s.split(',').map(&:to_i) @recent_usage, @daily_usage = usage_str.to_s.split(',').map(&:to_i) end |
Instance Attribute Details
#daily_limit ⇒ Object (readonly)
Returns the value of attribute daily_limit.
15 16 17 |
# File 'lib/strava/usage.rb', line 15 def daily_limit @daily_limit end |
#daily_usage ⇒ Object (readonly)
Returns the value of attribute daily_usage.
15 16 17 |
# File 'lib/strava/usage.rb', line 15 def daily_usage @daily_usage end |
#recent_limit ⇒ Object (readonly)
Returns the value of attribute recent_limit.
15 16 17 |
# File 'lib/strava/usage.rb', line 15 def recent_limit @recent_limit end |
#recent_usage ⇒ Object (readonly)
Returns the value of attribute recent_usage.
15 16 17 |
# File 'lib/strava/usage.rb', line 15 def recent_usage @recent_usage end |
Instance Method Details
#daily_pct ⇒ Float
Percentage of daily limit used.
32 33 34 |
# File 'lib/strava/usage.rb', line 32 def daily_pct @daily_usage.fdiv(@daily_limit) end |
#recent_pct ⇒ Float
Percentage of recent limit used.
25 26 27 |
# File 'lib/strava/usage.rb', line 25 def recent_pct @recent_usage.fdiv(@recent_limit) end |