class FtcEvent::Alliance

Attributes

event[R]
rank[R]

Public Class Methods

new(event, rank) click to toggle source
# File lib/ftc_event/alliance.rb, line 8
def initialize(event, rank)
  @event = event
  @rank = rank
end

Public Instance Methods

each_team() { |team| ... } click to toggle source
# 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() click to toggle source
# File lib/ftc_event/alliance.rb, line 13
def info
  event.db.query('SELECT * FROM alliances WHERE rank = ?', [rank])&.first
end
long_description() click to toggle source
# File lib/ftc_event/alliance.rb, line 43
def long_description
  "##{rank} #{long_team_list}"
end
long_team_list() click to toggle source
# File lib/ftc_event/alliance.rb, line 35
def long_team_list
  each_team.map(&:description).join(' and ')
end
short_description() click to toggle source
# File lib/ftc_event/alliance.rb, line 39
def short_description
  "##{rank} #{short_team_list}"
end
short_team_list() click to toggle source
# File lib/ftc_event/alliance.rb, line 31
def short_team_list
  each_team.map(&:number).join('/')
end
teams() click to toggle source
# File lib/ftc_event/alliance.rb, line 17
def teams
  [1, 2, 3].map { |n| info["team#{n}"] }.reject(&:zero?)
end