Class: Runkeeper::User
- Inherits:
-
Object
- Object
- Runkeeper::User
- Defined in:
- lib/runkeeper/user.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #activity_url(activity) ⇒ Object
- #fitness_activities ⇒ Object
- #id ⇒ Object
-
#initialize(token) ⇒ User
constructor
A new instance of User.
- #new_activity(attrs = {}) ⇒ Object
- #past_activities ⇒ Object
- #user_name ⇒ Object
Constructor Details
#initialize(token) ⇒ User
Returns a new instance of User.
6 7 8 9 |
# File 'lib/runkeeper/user.rb', line 6 def initialize(token) @token = token @connection = Connection.new(token) end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
4 5 6 |
# File 'lib/runkeeper/user.rb', line 4 def connection @connection end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
4 5 6 |
# File 'lib/runkeeper/user.rb', line 4 def token @token end |
Instance Method Details
#activity_url(activity) ⇒ Object
39 40 41 |
# File 'lib/runkeeper/user.rb', line 39 def activity_url(activity) File.join(profile, "activity", activity.id) end |
#fitness_activities ⇒ Object
27 28 29 |
# File 'lib/runkeeper/user.rb', line 27 def fitness_activities connection.fitness_activities end |
#id ⇒ Object
19 20 21 |
# File 'lib/runkeeper/user.rb', line 19 def id connection.user_response['userID'] end |
#new_activity(attrs = {}) ⇒ Object
35 36 37 |
# File 'lib/runkeeper/user.rb', line 35 def new_activity(attrs={}) Activity.new(connection, attrs) end |
#past_activities ⇒ Object
31 32 33 |
# File 'lib/runkeeper/user.rb', line 31 def past_activities connection.past_activities end |
#user_name ⇒ Object
23 24 25 |
# File 'lib/runkeeper/user.rb', line 23 def user_name profile =~ /\/user\/(.*)$/ && $1 end |