Class: SciolyFF::Interpreter::Tournament

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

Overview

Models a Science Olympiad tournament

Instance Attribute Summary collapse

Attributes inherited from Model

#tournament

Instance Method Summary collapse

Methods inherited from Model

#inspect

Constructor Details

#initialize(rep) ⇒ Tournament

Returns a new instance of Tournament.



8
9
10
# File 'lib/sciolyff/interpreter/tournament.rb', line 8

def initialize(rep)
  @rep = rep[:Tournament]
end

Instance Attribute Details

#eventsObject (readonly)

Returns the value of attribute events.



20
21
22
# File 'lib/sciolyff/interpreter/tournament.rb', line 20

def events
  @events
end

#penaltiesObject (readonly)

Returns the value of attribute penalties.



20
21
22
# File 'lib/sciolyff/interpreter/tournament.rb', line 20

def penalties
  @penalties
end

#placingsObject (readonly)

Returns the value of attribute placings.



20
21
22
# File 'lib/sciolyff/interpreter/tournament.rb', line 20

def placings
  @placings
end

#subdivisionsObject (readonly)

Returns the value of attribute subdivisions.



20
21
22
# File 'lib/sciolyff/interpreter/tournament.rb', line 20

def subdivisions
  @subdivisions
end

#teamsObject (readonly)

Returns the value of attribute teams.



20
21
22
# File 'lib/sciolyff/interpreter/tournament.rb', line 20

def teams
  @teams
end

Instance Method Details

#custom_maximum_place?Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/sciolyff/interpreter/tournament.rb', line 72

def custom_maximum_place?
  maximum_place != @teams.count { |t| !t.exhibition? }
end

#dateObject



52
53
54
# File 'lib/sciolyff/interpreter/tournament.rb', line 52

def date
  @rep[:date]
end

#divisionObject



44
45
46
# File 'lib/sciolyff/interpreter/tournament.rb', line 44

def division
  @rep[:division]
end

#exempt_placingsObject



68
69
70
# File 'lib/sciolyff/interpreter/tournament.rb', line 68

def exempt_placings
  @rep[:'exempt placings'] || 0
end

#exempt_placings?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/sciolyff/interpreter/tournament.rb', line 64

def exempt_placings?
  exempt_placings.positive?
end

#levelObject



36
37
38
# File 'lib/sciolyff/interpreter/tournament.rb', line 36

def level
  @rep[:level]
end


12
13
14
15
16
17
18
# File 'lib/sciolyff/interpreter/tournament.rb', line 12

def link_to_other_models(interpreter)
  @events = interpreter.events
  @teams = interpreter.teams
  @placings = interpreter.placings
  @penalties = interpreter.penalties
  @subdivisions = interpreter.subdivisions
end

#locationObject



32
33
34
# File 'lib/sciolyff/interpreter/tournament.rb', line 32

def location
  @rep[:location]
end

#maximum_placeObject



76
77
78
79
80
# File 'lib/sciolyff/interpreter/tournament.rb', line 76

def maximum_place
  return @rep[:'maximum place'] if @rep[:'maximum place']

  @teams.count { |t| !t.exhibition? }
end

#n_offsetObject



86
87
88
# File 'lib/sciolyff/interpreter/tournament.rb', line 86

def n_offset
  @rep[:'n offset'] || 0
end

#nameObject



24
25
26
# File 'lib/sciolyff/interpreter/tournament.rb', line 24

def name
  @rep[:name]
end

#per_event_n?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/sciolyff/interpreter/tournament.rb', line 82

def per_event_n?
  @rep[:'per-event n']
end

#short_nameObject



28
29
30
# File 'lib/sciolyff/interpreter/tournament.rb', line 28

def short_name
  @rep[:'short name']
end

#stateObject



40
41
42
# File 'lib/sciolyff/interpreter/tournament.rb', line 40

def state
  @rep[:state]
end

#subdivisions?Boolean

Returns:

  • (Boolean)


100
101
102
# File 'lib/sciolyff/interpreter/tournament.rb', line 100

def subdivisions?
  !@subdivisions.empty?
end

#ties?Boolean

Returns:

  • (Boolean)


90
91
92
# File 'lib/sciolyff/interpreter/tournament.rb', line 90

def ties?
  @ties ||= placings.map(&:tie?).any?
end

#ties_outside_of_maximum_places?Boolean

Returns:

  • (Boolean)


94
95
96
97
98
# File 'lib/sciolyff/interpreter/tournament.rb', line 94

def ties_outside_of_maximum_places?
  @ties_outside_of_maximum_places ||= placings.map do |p|
    p.tie? && !p.points_limited_by_maximum_place?
  end.any?
end

#worst_placings_droppedObject



60
61
62
# File 'lib/sciolyff/interpreter/tournament.rb', line 60

def worst_placings_dropped
  @rep[:'worst placings dropped'] || 0
end

#worst_placings_dropped?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/sciolyff/interpreter/tournament.rb', line 56

def worst_placings_dropped?
  worst_placings_dropped.positive?
end

#yearObject



48
49
50
# File 'lib/sciolyff/interpreter/tournament.rb', line 48

def year
  @rep[:year]
end