Class: M26::Ultra

Inherits:
Object
  • Object
show all
Defined in:
lib/m26_ultra.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rp, rt, wp, wt, sth = nil, debug = false) ⇒ Ultra

Returns a new instance of Ultra.



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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/m26_ultra.rb', line 19

def initialize(rp, rt, wp, wt, sth=nil, debug=false)
  @run_pace, @run_time = rp, rt
  @walk_pace, @walk_time = wp, wt
  @stopped_time_per_hour = sth
  @overall_mph = 0.0

  if stopped_time_per_hour
    @stopped_time_pct = stopped_time_per_hour.secs.to_f / M26::Constants::SECONDS_PER_HOUR.to_f
    @moving_time_pct  = 1.0 - stopped_time_pct
  else
    @stopped_time_pct = 0.0
    @moving_time_pct  = 1.0
  end

  @moving_secs     = (rt.secs + wt.secs).to_f
  @moving_run_pct  = rt.secs.to_f / moving_secs.to_f
  @moving_walk_pct = 1.0 - moving_run_pct

  @run_secs    = moving_run_pct  * rp.secs
  @walk_secs   = moving_walk_pct * wp.secs
  @avg_rw_secs = (run_secs + walk_secs).to_f

  @stop_factor   = 1.0 - stopped_time_pct
  @moving_time   = M26::ElapsedTime.new(avg_rw_secs)
  @total_time    = M26::ElapsedTime.new(avg_rw_secs.to_f / stop_factor)
  @moving_speed  = M26::Speed.new(mile, moving_time)
  @overall_speed = M26::Speed.new(mile, total_time)

  if debug
    puts "run_pace:         #{run_pace.inspect}"
    puts "run_time:         #{run_time.inspect}"
    puts "walk_pace:        #{walk_pace.inspect}"
    puts "walk_time:        #{walk_time.inspect}"
    puts "stopped_time_pct: #{stopped_time_pct.inspect}"
    puts "moving_time_pct:  #{moving_time_pct.inspect}"
    puts "moving_secs:      #{moving_secs.inspect}"
    puts "moving_run_pct:   #{moving_run_pct.inspect}"
    puts "moving_walk_pct:  #{moving_walk_pct.inspect}"
    puts "run_secs:         #{run_secs.inspect}"
    puts "walk_secs:        #{walk_secs.inspect}"
    puts "avg_rw_secs:      #{avg_rw_secs.inspect}"
    puts "stop_factor:      #{stop_factor}"
    puts "moving_time:      #{moving_time}"
    puts "total_time:       #{total_time}"
    puts "moving_speed:     #{moving_speed}"
    puts "overall_speed:    #{overall_speed}"
  end
end

Instance Attribute Details

#avg_rw_secsObject

Returns the value of attribute avg_rw_secs.



16
17
18
# File 'lib/m26_ultra.rb', line 16

def avg_rw_secs
  @avg_rw_secs
end

#moving_run_pctObject

Returns the value of attribute moving_run_pct.



14
15
16
# File 'lib/m26_ultra.rb', line 14

def moving_run_pct
  @moving_run_pct
end

#moving_secsObject

Returns the value of attribute moving_secs.



14
15
16
# File 'lib/m26_ultra.rb', line 14

def moving_secs
  @moving_secs
end

#moving_speedObject

Returns the value of attribute moving_speed.



17
18
19
# File 'lib/m26_ultra.rb', line 17

def moving_speed
  @moving_speed
end

#moving_timeObject

Returns the value of attribute moving_time.



15
16
17
# File 'lib/m26_ultra.rb', line 15

def moving_time
  @moving_time
end

#moving_time_pctObject

Returns the value of attribute moving_time_pct.



13
14
15
# File 'lib/m26_ultra.rb', line 13

def moving_time_pct
  @moving_time_pct
end

#moving_walk_pctObject

Returns the value of attribute moving_walk_pct.



14
15
16
# File 'lib/m26_ultra.rb', line 14

def moving_walk_pct
  @moving_walk_pct
end

#overall_speedObject

Returns the value of attribute overall_speed.



17
18
19
# File 'lib/m26_ultra.rb', line 17

def overall_speed
  @overall_speed
end

#run_paceObject

Returns the value of attribute run_pace.



11
12
13
# File 'lib/m26_ultra.rb', line 11

def run_pace
  @run_pace
end

#run_secsObject

Returns the value of attribute run_secs.



16
17
18
# File 'lib/m26_ultra.rb', line 16

def run_secs
  @run_secs
end

#run_timeObject

Returns the value of attribute run_time.



11
12
13
# File 'lib/m26_ultra.rb', line 11

def run_time
  @run_time
end

#stop_factorObject

Returns the value of attribute stop_factor.



15
16
17
# File 'lib/m26_ultra.rb', line 15

def stop_factor
  @stop_factor
end

#stopped_time_pctObject

Returns the value of attribute stopped_time_pct.



13
14
15
# File 'lib/m26_ultra.rb', line 13

def stopped_time_pct
  @stopped_time_pct
end

#stopped_time_per_hourObject

Returns the value of attribute stopped_time_per_hour.



13
14
15
# File 'lib/m26_ultra.rb', line 13

def stopped_time_per_hour
  @stopped_time_per_hour
end

#total_timeObject

Returns the value of attribute total_time.



15
16
17
# File 'lib/m26_ultra.rb', line 15

def total_time
  @total_time
end

#walk_paceObject

Returns the value of attribute walk_pace.



12
13
14
# File 'lib/m26_ultra.rb', line 12

def walk_pace
  @walk_pace
end

#walk_secsObject

Returns the value of attribute walk_secs.



16
17
18
# File 'lib/m26_ultra.rb', line 16

def walk_secs
  @walk_secs
end

#walk_timeObject

Returns the value of attribute walk_time.



12
13
14
# File 'lib/m26_ultra.rb', line 12

def walk_time
  @walk_time
end

Instance Method Details

#average_pace_per_mileObject



72
73
74
# File 'lib/m26_ultra.rb', line 72

def average_pace_per_mile
  "#{@tpm.as_hhmmss}"
end

#mileObject



68
69
70
# File 'lib/m26_ultra.rb', line 68

def mile
  M26::Distance.new(1.0)
end