Class: Dyno::Competitor
- Inherits:
-
Object
- Object
- Dyno::Competitor
- Defined in:
- lib/dyno/competitor.rb
Instance Attribute Summary collapse
-
#best_lap ⇒ Object
Returns the value of attribute best_lap.
-
#lap_times ⇒ Object
Returns the value of attribute lap_times.
-
#laps ⇒ Object
Returns the value of attribute laps.
-
#name ⇒ Object
Returns the value of attribute name.
-
#position ⇒ Object
Returns the value of attribute position.
-
#race_time ⇒ Object
Returns the value of attribute race_time.
-
#uid ⇒ Object
Returns the value of attribute uid.
-
#vehicle ⇒ Object
Returns the value of attribute vehicle.
Instance Method Summary collapse
-
#dnf! ⇒ Object
Flags this competitor as having not completed the event.
-
#dnf? ⇒ Boolean
Returns true if the competitor failed to finish.
-
#dsq! ⇒ Object
Flags this competitor has having been disqualified from the event.
-
#dsq? ⇒ Boolean
Returns true if the competitor was disqualified.
-
#finished? ⇒ Boolean
Returns true fi the competitor finished the event.
-
#initialize(name, properties = {}) ⇒ Competitor
constructor
A new instance of Competitor.
Constructor Details
#initialize(name, properties = {}) ⇒ Competitor
Returns a new instance of Competitor.
10 11 12 13 14 15 16 17 18 |
# File 'lib/dyno/competitor.rb', line 10 def initialize(name, properties = {}) @name = name @lap_times = properties.fetch(:laps, []) @dnf = false [:uid, :position, :vehicle, :laps, :race_time, :best_lap].each do |prop| instance_variable_set "@#{prop}", properties[prop] end end |
Instance Attribute Details
#best_lap ⇒ Object
Returns the value of attribute best_lap.
3 4 5 |
# File 'lib/dyno/competitor.rb', line 3 def best_lap @best_lap end |
#lap_times ⇒ Object
Returns the value of attribute lap_times.
3 4 5 |
# File 'lib/dyno/competitor.rb', line 3 def lap_times @lap_times end |
#laps ⇒ Object
Returns the value of attribute laps.
3 4 5 |
# File 'lib/dyno/competitor.rb', line 3 def laps @laps end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/dyno/competitor.rb', line 3 def name @name end |
#position ⇒ Object
Returns the value of attribute position.
3 4 5 |
# File 'lib/dyno/competitor.rb', line 3 def position @position end |
#race_time ⇒ Object
Returns the value of attribute race_time.
3 4 5 |
# File 'lib/dyno/competitor.rb', line 3 def race_time @race_time end |
#uid ⇒ Object
Returns the value of attribute uid.
3 4 5 |
# File 'lib/dyno/competitor.rb', line 3 def uid @uid end |
#vehicle ⇒ Object
Returns the value of attribute vehicle.
3 4 5 |
# File 'lib/dyno/competitor.rb', line 3 def vehicle @vehicle end |
Instance Method Details
#dnf! ⇒ Object
Flags this competitor as having not completed the event.
30 31 32 |
# File 'lib/dyno/competitor.rb', line 30 def dnf! @dnf = :dnf end |
#dnf? ⇒ Boolean
Returns true if the competitor failed to finish.
37 38 39 |
# File 'lib/dyno/competitor.rb', line 37 def dnf? @dnf == :dnf end |
#dsq! ⇒ Object
Flags this competitor has having been disqualified from the event.
44 45 46 |
# File 'lib/dyno/competitor.rb', line 44 def dsq! @dnf = :dsq end |
#dsq? ⇒ Boolean
Returns true if the competitor was disqualified.
51 52 53 |
# File 'lib/dyno/competitor.rb', line 51 def dsq? @dnf == :dsq end |
#finished? ⇒ Boolean
Returns true fi the competitor finished the event.
23 24 25 |
# File 'lib/dyno/competitor.rb', line 23 def finished? not dnf? and not dsq? end |