Class: RaceCheckpoint
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- RaceCheckpoint
- Defined in:
- app/models/race_checkpoint.rb
Class Method Summary collapse
Instance Method Summary collapse
- #fastest_leg(instance) ⇒ Object
- #fastest_time(instance) ⇒ Object
- #median_leg(instance) ⇒ Object
- #median_time(instance) ⇒ Object
- #next ⇒ Object
- #previous ⇒ Object
Class Method Details
.find_by_normalized_name(name) ⇒ Object
26 27 28 |
# File 'app/models/race_checkpoint.rb', line 26 def self.find_by_normalized_name(name) find_by_name(name.gsub(/\s+/, "_").downcase) end |
Instance Method Details
#fastest_leg(instance) ⇒ Object
34 35 36 |
# File 'app/models/race_checkpoint.rb', line 34 def fastest_leg(instance) self.times.in(instance).by_interval.first.interval_in_seconds end |
#fastest_time(instance) ⇒ Object
30 31 32 |
# File 'app/models/race_checkpoint.rb', line 30 def fastest_time(instance) self.times.in(instance).first.time_in_seconds end |
#median_leg(instance) ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'app/models/race_checkpoint.rb', line 47 def median_leg(instance) count = self.times.in(instance).count if count && count !=0 @median = self.times.in(instance).by_interval.single(count/2).first.interval_in_seconds else 0 end end |
#median_time(instance) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'app/models/race_checkpoint.rb', line 38 def median_time(instance) count = self.times.in(instance).count if count && count !=0 @median = self.times.in(instance).by_time.single(count/2).first.time_in_seconds else 0 end end |
#next ⇒ Object
22 23 24 |
# File 'app/models/race_checkpoint.rb', line 22 def next race.checkpoint_after(self) end |
#previous ⇒ Object
18 19 20 |
# File 'app/models/race_checkpoint.rb', line 18 def previous race.checkpoint_before(self) end |