Class: GoobyTcxExtractor
- Inherits:
-
GoobyBaseObject
- Object
- GoobyBaseObject
- GoobyTcxExtractor
- Defined in:
- lib/gooby_tcx_extractor.rb
Overview
Gooby = Google APIs + Ruby. Copyright 2009 by Chris Joakim. Gooby is available under GNU General Public License (GPL) license.
Constant Summary
Constants inherited from GoobyBaseObject
GoobyBaseObject::KILOMETERS_PER_MILE, GoobyBaseObject::METERS_PER_FOOT, GoobyBaseObject::MILES_PER_KILOMETER, GoobyBaseObject::SECONDS_PER_HOUR, GoobyBaseObject::UOM_KILOMETERS, GoobyBaseObject::UOM_MILES, GoobyBaseObject::UOM_YARDS, GoobyBaseObject::YARDS_PER_KILOMETER, GoobyBaseObject::YARDS_PER_MILE
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#files_extracted_info ⇒ Object
readonly
Returns the value of attribute files_extracted_info.
-
#files_written ⇒ Object
readonly
Returns the value of attribute files_written.
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
-
#out_dir ⇒ Object
readonly
Returns the value of attribute out_dir.
Instance Method Summary collapse
Methods inherited from GoobyBaseObject
boolean_config_value, config_value, get_config, set_config
Methods included from GoobyIO
#read_file_as_lines, #write_file, #write_lines
Methods included from GoobyIntrospection
Methods included from GoobyEnvironment
#array_param, #boolean_param, #command_line_arg, #float_param, #integer_param, #string_param
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
10 11 12 |
# File 'lib/gooby_tcx_extractor.rb', line 10 def file @file end |
#files_extracted_info ⇒ Object (readonly)
Returns the value of attribute files_extracted_info.
10 11 12 |
# File 'lib/gooby_tcx_extractor.rb', line 10 def files_extracted_info @files_extracted_info end |
#files_written ⇒ Object (readonly)
Returns the value of attribute files_written.
10 11 12 |
# File 'lib/gooby_tcx_extractor.rb', line 10 def files_written @files_written end |
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
10 11 12 |
# File 'lib/gooby_tcx_extractor.rb', line 10 def lines @lines end |
#out_dir ⇒ Object (readonly)
Returns the value of attribute out_dir.
10 11 12 |
# File 'lib/gooby_tcx_extractor.rb', line 10 def out_dir @out_dir end |
Instance Method Details
#extract(file, out_dir) ⇒ Object
12 13 14 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 |
# File 'lib/gooby_tcx_extractor.rb', line 12 def extract(file, out_dir) @file, @out_dir, @files_written, @files_extracted_info = file, out_dir, 0, {} puts "GoobyTcxExtractor - file: #{@file} out_dir: #{@out_dir}" @lines = read_file_as_lines(@file) puts "file has been read; line count: #{lines_read}" current_activity_start_index, current_activity_lines, current_id = 0, [], '' @lines.each_with_index { | line, index | if line.match('<Activity') current_activity_start_index = index current_activity_lines, current_id = [], '' current_activity_lines << xml_prolog_line current_activity_lines << root_xml_tag current_activity_lines << ' <Activities>' current_activity_lines << ' <!-- comment placeholder -->' end current_activity_lines << line.rstrip if line.match('<Id') && (index == (current_activity_start_index + 1)) current_id = scrub_id(line.strip) end if line.match('</Activity') current_activity_lines << ' </Activities>' current_activity_lines << '</TrainingCenterDatabase>' write_activity_file(current_activity_lines, current_id, current_activity_start_index) current_activity_lines = [] ObjectSpace.garbage_collect end } puts "files written: #{@files_written}" end |
#lines_read ⇒ Object
44 45 46 |
# File 'lib/gooby_tcx_extractor.rb', line 44 def lines_read @lines.size end |