Class: SciolyFF::Interpreter::Event

Inherits:
Model
  • Object
show all
Defined in:
lib/sciolyff/interpreter/event.rb

Overview

Models an instance of a Science Olympiad event at a specific tournament

Instance Attribute Summary collapse

Attributes inherited from Model

#tournament

Instance Method Summary collapse

Methods inherited from Model

#initialize, #inspect

Constructor Details

This class inherits a constructor from SciolyFF::Interpreter::Model

Instance Attribute Details

#placingsObject (readonly)

Returns the value of attribute placings.



16
17
18
# File 'lib/sciolyff/interpreter/event.rb', line 16

def placings
  @placings
end

#rawsObject (readonly)

Returns the value of attribute raws.



16
17
18
# File 'lib/sciolyff/interpreter/event.rb', line 16

def raws
  @raws
end

Instance Method Details

#high_score_wins?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/sciolyff/interpreter/event.rb', line 30

def high_score_wins?
  !low_score_wins?
end


8
9
10
11
12
13
14
# File 'lib/sciolyff/interpreter/event.rb', line 8

def link_to_other_models(interpreter)
  super
  @placings = interpreter.placings.select { |p| p.event == self }
  @placings_by_team =
    @placings.group_by(&:team).transform_values!(&:first)
  @raws = @placings.select(&:raw?).map(&:raw).sort
end

#low_score_wins?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/sciolyff/interpreter/event.rb', line 34

def low_score_wins?
  @rep[:scoring] == 'low'
end

#maximum_placeObject



42
43
44
45
46
47
48
49
50
51
# File 'lib/sciolyff/interpreter/event.rb', line 42

def maximum_place
  @maximum_place ||=
    if trial?
      placings.size
    elsif tournament.per_event_n?
      [per_event_maximum_place, tournament.maximum_place].min
    else
      tournament.maximum_place
    end
end

#maximum_pointsObject



53
54
55
# File 'lib/sciolyff/interpreter/event.rb', line 53

def maximum_points
  maximum_place + 2
end

#nameObject



18
19
20
# File 'lib/sciolyff/interpreter/event.rb', line 18

def name
  @rep[:name]
end

#placing_for(team) ⇒ Object



38
39
40
# File 'lib/sciolyff/interpreter/event.rb', line 38

def placing_for(team)
  @placings_by_team[team]
end

#trial?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/sciolyff/interpreter/event.rb', line 22

def trial?
  @rep[:trial] || false
end

#trialed?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/sciolyff/interpreter/event.rb', line 26

def trialed?
  @rep[:trialed] || false
end