Class: Dyno::Competitor

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, properties = {}) ⇒ Competitor

Returns a new instance of Competitor.

Parameters:

  • name (String)

    The competitor’s name.

  • properties (Hash) (defaults to: {})

    Extra information about the 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_lapObject

Returns the value of attribute best_lap.



3
4
5
# File 'lib/dyno/competitor.rb', line 3

def best_lap
  @best_lap
end

#lap_timesObject

Returns the value of attribute lap_times.



3
4
5
# File 'lib/dyno/competitor.rb', line 3

def lap_times
  @lap_times
end

#lapsObject

Returns the value of attribute laps.



3
4
5
# File 'lib/dyno/competitor.rb', line 3

def laps
  @laps
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/dyno/competitor.rb', line 3

def name
  @name
end

#positionObject

Returns the value of attribute position.



3
4
5
# File 'lib/dyno/competitor.rb', line 3

def position
  @position
end

#race_timeObject

Returns the value of attribute race_time.



3
4
5
# File 'lib/dyno/competitor.rb', line 3

def race_time
  @race_time
end

#uidObject

Returns the value of attribute uid.



3
4
5
# File 'lib/dyno/competitor.rb', line 3

def uid
  @uid
end

#vehicleObject

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.

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


23
24
25
# File 'lib/dyno/competitor.rb', line 23

def finished?
  not dnf? and not dsq?
end