Class: SciolyFF::Interpreter
- Inherits:
-
Object
- Object
- SciolyFF::Interpreter
- Includes:
- HTML, Subdivisions, Tiebreaks
- Defined in:
- lib/sciolyff/interpreter.rb
Overview
Interprets the YAML representation of a SciolyFF file through objects that respond to idiomatic Ruby method calls
Defined Under Namespace
Modules: Bids, HTML, Subdivisions, Tiebreaks Classes: Event, Model, Penalty, Placing, Team, 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.
-
#teams ⇒ Object
readonly
Returns the value of attribute teams.
-
#tournament ⇒ Object
readonly
Returns the value of attribute tournament.
Instance Method Summary collapse
-
#initialize(rep) ⇒ Interpreter
constructor
A new instance of Interpreter.
- #subdivisions ⇒ Object
Methods included from HTML
Constructor Details
#initialize(rep) ⇒ Interpreter
Returns a new instance of Interpreter.
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/sciolyff/interpreter.rb', line 19 def initialize(rep) if rep.instance_of? String rep = Psych.safe_load(rep, permitted_classes: [Date], symbolize_names: true) end create_models(@rep = rep) link_models(self) sort_events_naturally sort_teams_by_rank end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
17 18 19 |
# File 'lib/sciolyff/interpreter.rb', line 17 def events @events end |
#penalties ⇒ Object (readonly)
Returns the value of attribute penalties.
17 18 19 |
# File 'lib/sciolyff/interpreter.rb', line 17 def penalties @penalties end |
#placings ⇒ Object (readonly)
Returns the value of attribute placings.
17 18 19 |
# File 'lib/sciolyff/interpreter.rb', line 17 def placings @placings end |
#teams ⇒ Object (readonly)
Returns the value of attribute teams.
17 18 19 |
# File 'lib/sciolyff/interpreter.rb', line 17 def teams @teams end |
#tournament ⇒ Object (readonly)
Returns the value of attribute tournament.
17 18 19 |
# File 'lib/sciolyff/interpreter.rb', line 17 def tournament @tournament end |
Instance Method Details
#subdivisions ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/sciolyff/interpreter.rb', line 32 def subdivisions @subdivisions ||= teams.map(&:subdivision) .uniq .compact .map { |sub| [sub, Interpreter.new(subdivision_rep(sub))] } .to_h end |