Sha256: 8beaff58af2d08c8e1fa423a40d1f28d1f143920e875c876fae83b81326d8364

Contents?: true

Size: 857 Bytes

Versions: 1

Compression:

Stored size: 857 Bytes

Contents

# frozen_string_literal: true

module FtcEvent
  class Team
    attr_reader :event
    attr_reader :number

    def initialize(event, number)
      @event = event
      @number = number
    end

    def info
      event.db.query('SELECT * FROM teamInfo WHERE number = ?', [number])&.first
    end

    def name
      info && info['name']
    end

    def school
      info && info['school']
    end

    def city
      info && info['city']
    end

    def state
      info && info['state']
    end

    def country
      info && info['country']
    end

    def location
      return unless info

      [
        city,
        state,
        country != 'USA' ? country : nil
      ].reject(&:nil?).join(', ')
    end

    def description
      "#{number} #{name}"
    end

    def full_description
      "#{description} from #{location}"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ftc_event-0.1.0 lib/ftc_event/team.rb