Class: Joule::Base::Parser

Inherits:
Object
  • Object
show all
Includes:
Calculator::MarkerCalculator, Calculator::PeakPowerCalculator
Defined in:
lib/joule/base/parser.rb

Direct Known Subclasses

CSV::Parser, SRM::Parser, TCX::Parser

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Calculator::PeakPowerCalculator

#calculate_peak_power_value, #calculate_peak_power_values

Methods included from Calculator::MarkerCalculator

#calculate_marker_averages, #calculate_marker_maximums, #calculate_marker_totals, #calculate_marker_training_metrics, #calculate_marker_values

Constructor Details

#initialize(data) ⇒ Parser

Returns a new instance of Parser.



9
10
11
12
# File 'lib/joule/base/parser.rb', line 9

def initialize(data)
  @data = data  
  @workout = Workout.new
end

Instance Attribute Details

#workoutObject

Returns the value of attribute workout.



7
8
9
# File 'lib/joule/base/parser.rb', line 7

def workout
  @workout
end

Instance Method Details

#parse(options = {}) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/joule/base/parser.rb', line 25

def parse(options = {})

  parse_properties
  parse_workout
  
  if(options[:calculate_marker_values])
    calculate_marker_values()
  end

  if(options[:calculate_peak_power_values])
    calculate_peak_power_values(:durations => options[:durations], :total_duration => @workout.markers.first.duration_seconds)
  end
  @workout
end

#parse_propertiesObject

Raises:

  • (NotImplementedError)


44
45
46
# File 'lib/joule/base/parser.rb', line 44

def parse_properties
  raise NotImplementedError
end

#parse_workoutObject

Raises:

  • (NotImplementedError)


40
41
42
# File 'lib/joule/base/parser.rb', line 40

def parse_workout
  raise NotImplementedError
end