Class: FtcEvent::Alliance
- Inherits:
-
Object
- Object
- FtcEvent::Alliance
- Defined in:
- lib/ftc_event/alliance.rb
Instance Attribute Summary collapse
-
#event ⇒ Object
readonly
Returns the value of attribute event.
-
#rank ⇒ Object
readonly
Returns the value of attribute rank.
Instance Method Summary collapse
- #each_team ⇒ Object
- #info ⇒ Object
-
#initialize(event, rank) ⇒ Alliance
constructor
A new instance of Alliance.
- #long_description ⇒ Object
- #long_team_list ⇒ Object
- #short_description ⇒ Object
- #short_team_list ⇒ Object
- #teams ⇒ Object
Constructor Details
#initialize(event, rank) ⇒ Alliance
Returns a new instance of Alliance.
8 9 10 11 |
# File 'lib/ftc_event/alliance.rb', line 8 def initialize(event, rank) @event = event @rank = rank end |
Instance Attribute Details
#event ⇒ Object (readonly)
Returns the value of attribute event.
5 6 7 |
# File 'lib/ftc_event/alliance.rb', line 5 def event @event end |
#rank ⇒ Object (readonly)
Returns the value of attribute rank.
6 7 8 |
# File 'lib/ftc_event/alliance.rb', line 6 def rank @rank end |
Instance Method Details
#each_team ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/ftc_event/alliance.rb', line 21 def each_team return enum_for(:each_team) unless block_given? teams.each do |team_number| yield event.team(team_number) end nil end |
#info ⇒ Object
13 14 15 |
# File 'lib/ftc_event/alliance.rb', line 13 def info event.db.query('SELECT * FROM alliances WHERE rank = ?', [rank])&.first end |
#long_description ⇒ Object
43 44 45 |
# File 'lib/ftc_event/alliance.rb', line 43 def long_description "##{rank} #{long_team_list}" end |
#long_team_list ⇒ Object
35 36 37 |
# File 'lib/ftc_event/alliance.rb', line 35 def long_team_list each_team.map(&:description).join(' and ') end |
#short_description ⇒ Object
39 40 41 |
# File 'lib/ftc_event/alliance.rb', line 39 def short_description "##{rank} #{short_team_list}" end |
#short_team_list ⇒ Object
31 32 33 |
# File 'lib/ftc_event/alliance.rb', line 31 def short_team_list each_team.map(&:number).join('/') end |
#teams ⇒ Object
17 18 19 |
# File 'lib/ftc_event/alliance.rb', line 17 def teams [1, 2, 3].map { |n| info["team#{n}"] }.reject(&:zero?) end |