class FtcEvent::Event

Attributes

db[R]

Public Class Methods

new(filename) click to toggle source
# File lib/ftc_event/event.rb, line 7
def initialize(filename)
  @db = SQLite3::Database.new(filename, results_as_hash: true)
end

Public Instance Methods

alliance(rank) click to toggle source
# File lib/ftc_event/event.rb, line 67
def alliance(rank)
  Alliance.new(self, rank)
end
code() click to toggle source
# File lib/ftc_event/event.rb, line 25
def code
  config['code']
end
config() click to toggle source
# File lib/ftc_event/event.rb, line 11
def config
  db.execute('SELECT key, value FROM config').each_with_object({}) do |row, h|
    h[row['key']] = row['value']
  end
end
each_phase() { |phase| ... } click to toggle source
# File lib/ftc_event/event.rb, line 79
def each_phase
  return enum_for(:each_phase) unless block_given?

  phases.each do |phase|
    yield phase unless phase.matches.empty?
  end

  nil
end
each_team() { |team(number)| ... } click to toggle source
# File lib/ftc_event/event.rb, line 53
def each_team
  return enum_for(:each_team) unless block_given?

  teams.each do |number|
    yield team(number)
  end

  nil
end
eliminations() click to toggle source
# File lib/ftc_event/event.rb, line 71
def eliminations
  Eliminations.new(self)
end
end() click to toggle source
# File lib/ftc_event/event.rb, line 41
def end
  Time.at(config['end'].to_f / 1000.0)
end
league(code = leagues.first) click to toggle source
# File lib/ftc_event/event.rb, line 45
def league(code = leagues.first)
  League.new(self, code) if code
end
leagues() click to toggle source
# File lib/ftc_event/event.rb, line 17
def leagues
  db.execute('SELECT code FROM leagueInfo').map { |row| row['code'] }
end
name() click to toggle source
# File lib/ftc_event/event.rb, line 29
def name
  config['name'].gsub(/\s*FTC\s*/, '').strip
end
phases() click to toggle source
# File lib/ftc_event/event.rb, line 75
def phases
  [qualifications, eliminations]
end
qualifications() click to toggle source
# File lib/ftc_event/event.rb, line 63
def qualifications
  Qualifications.new(self)
end
short_name() click to toggle source
# File lib/ftc_event/event.rb, line 33
def short_name
  code.upcase
end
start() click to toggle source
# File lib/ftc_event/event.rb, line 37
def start
  Time.at(config['start'].to_f / 1000.0)
end
team(number) click to toggle source
# File lib/ftc_event/event.rb, line 49
def team(number)
  Team.new(self, number)
end
teams() click to toggle source
# File lib/ftc_event/event.rb, line 21
def teams
  db.execute('SELECT number FROM teams').map { |row| row['number'] }
end