Class: FtcEvent::League
- Inherits:
-
Object
- Object
- FtcEvent::League
- Defined in:
- lib/ftc_event/league.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#event ⇒ Object
readonly
Returns the value of attribute event.
Instance Method Summary collapse
- #each_team ⇒ Object
- #info ⇒ Object
-
#initialize(event, code) ⇒ League
constructor
A new instance of League.
- #name ⇒ Object
- #teams ⇒ Object
Constructor Details
#initialize(event, code) ⇒ League
Returns a new instance of League.
8 9 10 11 |
# File 'lib/ftc_event/league.rb', line 8 def initialize(event, code) @event = event @code = code end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
6 7 8 |
# File 'lib/ftc_event/league.rb', line 6 def code @code end |
#event ⇒ Object (readonly)
Returns the value of attribute event.
5 6 7 |
# File 'lib/ftc_event/league.rb', line 5 def event @event end |
Instance Method Details
#each_team ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/ftc_event/league.rb', line 26 def each_team return enum_for(:each_team) unless block_given? teams.each do |number| yield event.team(number) end nil end |
#info ⇒ Object
13 14 15 |
# File 'lib/ftc_event/league.rb', line 13 def info event.db.query('SELECT * FROM leagueInfo WHERE code = ?', [code])&.first end |
#name ⇒ Object
17 18 19 |
# File 'lib/ftc_event/league.rb', line 17 def name info && info['name'] end |
#teams ⇒ Object
21 22 23 24 |
# File 'lib/ftc_event/league.rb', line 21 def teams result = event.db.query('SELECT team FROM leagueMembers WHERE code = ?', [code]) result&.map { |row| row['team'] } end |