Class: Strava::App
Constant Summary collapse
- NAME =
'Strava Dashboard'- DESCRIPTION =
'Fetchs data from strava to report what you have done'
Instance Attribute Summary collapse
-
#activities ⇒ Object
Returns the value of attribute activities.
-
#client ⇒ Object
Returns the value of attribute client.
-
#graph ⇒ Object
Returns the value of attribute graph.
-
#publicize ⇒ Object
Returns the value of attribute publicize.
-
#simulate ⇒ Object
Returns the value of attribute simulate.
-
#types ⇒ Object
Returns the value of attribute types.
Instance Method Summary collapse
- #configure_api_client ⇒ Object
-
#initialize ⇒ App
constructor
A new instance of App.
- #run ⇒ Object
Constructor Details
#initialize ⇒ App
Returns a new instance of App.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/strava/app.rb', line 15 def initialize config.config_file_base_name = Strava::BASE_NAME config.describes_application app_name: NAME, app_version: Strava::VERSION, app_description: DESCRIPTION config.add_command_line_section('Strava options') do |slop| slop.on :strava_access_token, 'Strava access token', argument: true, as: String slop.on :activity, 'Display this activity type only (Run, Ride, Swim)', argument: true slop.on :graph, 'Display a graph instead of a table', argument: false slop.on :scope, 'Display limited scoped activities (public or private)', argument: true slop.on :publicize, 'Make private activities public', argument: false end if config[:help] puts config.command_line_help exit 0 end if config[:activity] @types = [config[:activity]] else @types = %w(Run Ride Swim) end @graph = config[:graph] @scope = config[:scope] @cache_key = config[:cache_key] || "activities" @publicize = config[:publicize] @simulate = config[:simulate] @activities = [] end |
Instance Attribute Details
#activities ⇒ Object
Returns the value of attribute activities.
13 14 15 |
# File 'lib/strava/app.rb', line 13 def activities @activities end |
#client ⇒ Object
Returns the value of attribute client.
13 14 15 |
# File 'lib/strava/app.rb', line 13 def client @client end |
#graph ⇒ Object
Returns the value of attribute graph.
13 14 15 |
# File 'lib/strava/app.rb', line 13 def graph @graph end |
#publicize ⇒ Object
Returns the value of attribute publicize.
13 14 15 |
# File 'lib/strava/app.rb', line 13 def publicize @publicize end |
#simulate ⇒ Object
Returns the value of attribute simulate.
13 14 15 |
# File 'lib/strava/app.rb', line 13 def simulate @simulate end |
#types ⇒ Object
Returns the value of attribute types.
13 14 15 |
# File 'lib/strava/app.rb', line 13 def types @types end |
Instance Method Details
#configure_api_client ⇒ Object
47 48 49 |
# File 'lib/strava/app.rb', line 47 def configure_api_client @client = Strava::Api::V3::Client.new(access_token: config[:strava_access_token]) end |
#run ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/strava/app.rb', line 51 def run configure_api_client fetch_activities_data for type in types if publicize publicize_activities(type) elsif graph output_screen = build_graph_speed(type) else output_screen = build_table(type) end if output_screen.nil? puts "No activity found. Go out and start #{type}ing!" else puts output_screen end puts "\n" end end |