Class: RunKeeperActivities::User
- Inherits:
-
Object
- Object
- RunKeeperActivities::User
- Defined in:
- lib/runkeeper_activities/user.rb
Instance Attribute Summary collapse
-
#activities ⇒ Object
readonly
Returns the value of attribute activities.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#profile_image_url ⇒ Object
readonly
Returns the value of attribute profile_image_url.
-
#profile_url ⇒ Object
readonly
Returns the value of attribute profile_url.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Class Method Summary collapse
Instance Method Summary collapse
- #activities_url ⇒ Object
- #calories_unit ⇒ Object
- #distance_unit ⇒ Object
- #duration_unit ⇒ Object
- #elevation_unit ⇒ Object
- #get_profile ⇒ Object
-
#initialize(username) ⇒ User
constructor
A new instance of User.
- #pace_unit ⇒ Object
- #page ⇒ Object
- #speed_unit ⇒ Object
Constructor Details
#initialize(username) ⇒ User
Returns a new instance of User.
15 16 17 18 |
# File 'lib/runkeeper_activities/user.rb', line 15 def initialize(username) @username = username @profile_url = Utils.runkeeper_url("/user/#{username}/profile") end |
Instance Attribute Details
#activities ⇒ Object (readonly)
Returns the value of attribute activities.
3 4 5 |
# File 'lib/runkeeper_activities/user.rb', line 3 def activities @activities end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/runkeeper_activities/user.rb', line 3 def name @name end |
#profile_image_url ⇒ Object (readonly)
Returns the value of attribute profile_image_url.
3 4 5 |
# File 'lib/runkeeper_activities/user.rb', line 3 def profile_image_url @profile_image_url end |
#profile_url ⇒ Object (readonly)
Returns the value of attribute profile_url.
3 4 5 |
# File 'lib/runkeeper_activities/user.rb', line 3 def profile_url @profile_url end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
3 4 5 |
# File 'lib/runkeeper_activities/user.rb', line 3 def username @username end |
Class Method Details
.find_by_username(username) ⇒ Object
10 11 12 |
# File 'lib/runkeeper_activities/user.rb', line 10 def find_by_username(username) RunKeeperActivities::User.new(username).tap { |_user| _user.get_profile } end |
Instance Method Details
#activities_url ⇒ Object
20 21 22 |
# File 'lib/runkeeper_activities/user.rb', line 20 def activities_url @activities_url ||= Utils.runkeeper_url("/user/#{username}/activity") end |
#calories_unit ⇒ Object
40 41 42 |
# File 'lib/runkeeper_activities/user.rb', line 40 def calories_unit @calories_unit ||= page.at_css('#statsCalories .unitText').text end |
#distance_unit ⇒ Object
24 25 26 |
# File 'lib/runkeeper_activities/user.rb', line 24 def distance_unit @distance_unit ||= page.at_css('#statsDistance .unitText').text end |
#duration_unit ⇒ Object
28 29 30 |
# File 'lib/runkeeper_activities/user.rb', line 28 def duration_unit @duration_unit ||= page.at_css('#statsDuration .unitText').text end |
#elevation_unit ⇒ Object
44 45 46 |
# File 'lib/runkeeper_activities/user.rb', line 44 def elevation_unit @elevation_unit ||= page.at_css('#statsElevation .unitText').text end |
#get_profile ⇒ Object
53 54 55 56 57 58 |
# File 'lib/runkeeper_activities/user.rb', line 53 def get_profile page.at_css('.profileBoxSmall img').tap do |_profile_image_tag| @name = _profile_image_tag['title'] @profile_image_url = _profile_image_tag['src'] end end |
#pace_unit ⇒ Object
32 33 34 |
# File 'lib/runkeeper_activities/user.rb', line 32 def pace_unit @pace_unit ||= page.at_css('#statsPace .unitText').text end |
#page ⇒ Object
60 61 62 |
# File 'lib/runkeeper_activities/user.rb', line 60 def page @page ||= Nokogiri::HTML(open(activities_url)) end |
#speed_unit ⇒ Object
36 37 38 |
# File 'lib/runkeeper_activities/user.rb', line 36 def speed_unit @speed_unit ||= page.at_css('#statsSpeed .unitText').text end |