Class: BenchPress::Result
- Inherits:
-
Object
- Object
- BenchPress::Result
- Defined in:
- lib/bench_press/result.rb
Instance Attribute Summary collapse
-
#runnables ⇒ Object
readonly
Returns the value of attribute runnables.
Instance Method Summary collapse
- #evaluate ⇒ Object
- #fastest ⇒ Object
- #grade ⇒ Object
-
#initialize(runnables) ⇒ Result
constructor
A new instance of Result.
- #longest_name ⇒ Object
- #longest_run_time ⇒ Object
- #slowest ⇒ Object
- #sort ⇒ Object
Constructor Details
#initialize(runnables) ⇒ Result
Returns a new instance of Result.
5 6 7 |
# File 'lib/bench_press/result.rb', line 5 def initialize(runnables) @runnables = runnables end |
Instance Attribute Details
#runnables ⇒ Object (readonly)
Returns the value of attribute runnables.
3 4 5 |
# File 'lib/bench_press/result.rb', line 3 def runnables @runnables end |
Instance Method Details
#evaluate ⇒ Object
9 10 11 12 13 |
# File 'lib/bench_press/result.rb', line 9 def evaluate sort grade self end |
#fastest ⇒ Object
20 21 22 |
# File 'lib/bench_press/result.rb', line 20 def fastest runnables.first end |
#grade ⇒ Object
36 37 38 39 40 41 |
# File 'lib/bench_press/result.rb', line 36 def grade runnables.each do |r| r.fastest = fastest == r r.percent_slower = percentage_slower(r.run_time) end end |
#longest_name ⇒ Object
28 29 30 |
# File 'lib/bench_press/result.rb', line 28 def longest_name runnables.sort_by {|r| r.name.size}.last.name end |
#longest_run_time ⇒ Object
32 33 34 |
# File 'lib/bench_press/result.rb', line 32 def longest_run_time runnables.sort_by {|r| r.run_time.to_s.size}.last.run_time.to_s end |
#slowest ⇒ Object
24 25 26 |
# File 'lib/bench_press/result.rb', line 24 def slowest runnables.last end |
#sort ⇒ Object
15 16 17 18 |
# File 'lib/bench_press/result.rb', line 15 def sort runnables.each {|r| r.run} @runnables = runnables.sort_by {|r| r.run_time} end |