Class: FitnioExport
- Inherits:
-
Object
- Object
- FitnioExport
- Defined in:
- lib/fitnio_export.rb
Defined Under Namespace
Classes: AuthenticationError
Constant Summary collapse
- MILE_TO_KM =
1.609344- SIGNIN_URL =
"http://fitnio.com/signIn.htm"- DATA_URL =
"http://fitnio.com/mapData.htm"- SPORT_TYPES =
{ 'W' => 'Walking', 'R' => 'Running', 'B' => 'Biking' }
- GPX_HEADER =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<gpx\nversion=\"1.1\"\ncreator=\"fitnio_export (http://github.com/psionides/fitnio_export)\"\nxmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\nxmlns=\"http://www.topografix.com/GPX/1/1\"\nxsi:schemaLocation=\"http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd\"\nxmlns:gpxtpx=\"http://www.garmin.com/xmlschemas/TrackPointExtension/v1\">\n<trk>\n"- GPX_FOOTER =
"</trkseg>\n</trk>\n</gpx>\n"
Instance Method Summary collapse
-
#initialize(email, password) ⇒ FitnioExport
constructor
A new instance of FitnioExport.
- #start ⇒ Object
Constructor Details
#initialize(email, password) ⇒ FitnioExport
Returns a new instance of FitnioExport.
38 39 40 41 42 43 44 |
# File 'lib/fitnio_export.rb', line 38 def initialize(email, password) @email = email @password = password @logger = Logger.new(STDOUT) @logger.formatter = lambda { |type, time, program, text| "#{time}: #{text}\n" } @browser = Mechanize.new end |
Instance Method Details
#start ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/fitnio_export.rb', line 46 def start rows = get_activity_rows rows.each do |row| id = row['id'] json = get_activity_json(id) date_row = row.search('td')[1] date_string = date_row.to_s.gsub(/<.*?>/, ' ').strip sprite = row.search('.gs-sprite')[0] type = sprite['class'][/me-(\w)/].split('-').last save_data_file(json, date_string, type) end log "Done." end |