Class: SciolyFF::Interpreter::Tournament
- Defined in:
- lib/sciolyff/interpreter/tournament.rb
Overview
Models a Science Olympiad tournament
Instance Attribute Summary collapse
-
#events ⇒ Object
readonly
Returns the value of attribute events.
-
#penalties ⇒ Object
readonly
Returns the value of attribute penalties.
-
#placings ⇒ Object
readonly
Returns the value of attribute placings.
-
#subdivisions ⇒ Object
readonly
Returns the value of attribute subdivisions.
-
#teams ⇒ Object
readonly
Returns the value of attribute teams.
Attributes inherited from Model
Instance Method Summary collapse
- #custom_maximum_place? ⇒ Boolean
- #date ⇒ Object
- #division ⇒ Object
- #exempt_placings ⇒ Object
- #exempt_placings? ⇒ Boolean
-
#initialize(rep) ⇒ Tournament
constructor
A new instance of Tournament.
- #level ⇒ Object
- #link_to_other_models(interpreter) ⇒ Object
- #location ⇒ Object
- #maximum_place ⇒ Object
- #n_offset ⇒ Object
- #name ⇒ Object
- #per_event_n? ⇒ Boolean
- #short_name ⇒ Object
- #state ⇒ Object
- #subdivisions? ⇒ Boolean
- #ties? ⇒ Boolean
- #ties_outside_of_maximum_places? ⇒ Boolean
- #worst_placings_dropped ⇒ Object
- #worst_placings_dropped? ⇒ Boolean
- #year ⇒ Object
Methods inherited from Model
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
#events ⇒ Object (readonly)
Returns the value of attribute events.
20 21 22 |
# File 'lib/sciolyff/interpreter/tournament.rb', line 20 def events @events end |
#penalties ⇒ Object (readonly)
Returns the value of attribute penalties.
20 21 22 |
# File 'lib/sciolyff/interpreter/tournament.rb', line 20 def penalties @penalties end |
#placings ⇒ Object (readonly)
Returns the value of attribute placings.
20 21 22 |
# File 'lib/sciolyff/interpreter/tournament.rb', line 20 def placings @placings end |
#subdivisions ⇒ Object (readonly)
Returns the value of attribute subdivisions.
20 21 22 |
# File 'lib/sciolyff/interpreter/tournament.rb', line 20 def subdivisions @subdivisions end |
#teams ⇒ Object (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
72 73 74 |
# File 'lib/sciolyff/interpreter/tournament.rb', line 72 def custom_maximum_place? maximum_place != @teams.count { |t| !t.exhibition? } end |
#date ⇒ Object
52 53 54 |
# File 'lib/sciolyff/interpreter/tournament.rb', line 52 def date @rep[:date] end |
#division ⇒ Object
44 45 46 |
# File 'lib/sciolyff/interpreter/tournament.rb', line 44 def division @rep[:division] end |
#exempt_placings ⇒ Object
68 69 70 |
# File 'lib/sciolyff/interpreter/tournament.rb', line 68 def exempt_placings @rep[:'exempt placings'] || 0 end |
#exempt_placings? ⇒ Boolean
64 65 66 |
# File 'lib/sciolyff/interpreter/tournament.rb', line 64 def exempt_placings? exempt_placings.positive? end |
#level ⇒ Object
36 37 38 |
# File 'lib/sciolyff/interpreter/tournament.rb', line 36 def level @rep[:level] end |
#link_to_other_models(interpreter) ⇒ Object
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 |
#location ⇒ Object
32 33 34 |
# File 'lib/sciolyff/interpreter/tournament.rb', line 32 def location @rep[:location] end |
#maximum_place ⇒ Object
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_offset ⇒ Object
86 87 88 |
# File 'lib/sciolyff/interpreter/tournament.rb', line 86 def n_offset @rep[:'n offset'] || 0 end |
#name ⇒ Object
24 25 26 |
# File 'lib/sciolyff/interpreter/tournament.rb', line 24 def name @rep[:name] end |
#per_event_n? ⇒ Boolean
82 83 84 |
# File 'lib/sciolyff/interpreter/tournament.rb', line 82 def per_event_n? @rep[:'per-event n'] end |
#short_name ⇒ Object
28 29 30 |
# File 'lib/sciolyff/interpreter/tournament.rb', line 28 def short_name @rep[:'short name'] end |
#state ⇒ Object
40 41 42 |
# File 'lib/sciolyff/interpreter/tournament.rb', line 40 def state @rep[:state] end |
#subdivisions? ⇒ Boolean
100 101 102 |
# File 'lib/sciolyff/interpreter/tournament.rb', line 100 def subdivisions? !@subdivisions.empty? end |
#ties? ⇒ 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
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_dropped ⇒ Object
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
56 57 58 |
# File 'lib/sciolyff/interpreter/tournament.rb', line 56 def worst_placings_dropped? worst_placings_dropped.positive? end |
#year ⇒ Object
48 49 50 |
# File 'lib/sciolyff/interpreter/tournament.rb', line 48 def year @rep[:year] end |