Class: FtcEvent::Team

Inherits:
Object
  • Object
show all
Defined in:
lib/ftc_event/team.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event, number) ⇒ Team

Returns a new instance of Team.



8
9
10
11
# File 'lib/ftc_event/team.rb', line 8

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

Instance Attribute Details

#eventObject (readonly)

Returns the value of attribute event.



5
6
7
# File 'lib/ftc_event/team.rb', line 5

def event
  @event
end

#numberObject (readonly)

Returns the value of attribute number.



6
7
8
# File 'lib/ftc_event/team.rb', line 6

def number
  @number
end

Instance Method Details

#cityObject



25
26
27
# File 'lib/ftc_event/team.rb', line 25

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

#countryObject



33
34
35
# File 'lib/ftc_event/team.rb', line 33

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

#descriptionObject



47
48
49
# File 'lib/ftc_event/team.rb', line 47

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

#full_descriptionObject



51
52
53
# File 'lib/ftc_event/team.rb', line 51

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

#infoObject



13
14
15
# File 'lib/ftc_event/team.rb', line 13

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

#locationObject



37
38
39
40
41
42
43
44
45
# File 'lib/ftc_event/team.rb', line 37

def location
  return unless info

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

#nameObject



17
18
19
# File 'lib/ftc_event/team.rb', line 17

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

#schoolObject



21
22
23
# File 'lib/ftc_event/team.rb', line 21

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

#stateObject



29
30
31
# File 'lib/ftc_event/team.rb', line 29

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