Class: Competitor

Inherits:
Object
  • Object
show all
Defined in:
lib/barbershop_contestants/competitor.rb

Overview

comprises two types: quartet and chorus each has an m-to-m relationship with Contest::Quartet and Contest::Chorus, respectively

Direct Known Subclasses

Chorus, Quartet

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#districtObject

Returns the value of attribute district.



5
6
7
# File 'lib/barbershop_contestants/competitor.rb', line 5

def district
  @district
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/barbershop_contestants/competitor.rb', line 5

def name
  @name
end

#performancesObject

Returns the value of attribute performances.



5
6
7
# File 'lib/barbershop_contestants/competitor.rb', line 5

def performances
  @performances
end

#typeObject

Returns the value of attribute type.



5
6
7
# File 'lib/barbershop_contestants/competitor.rb', line 5

def type
  @type
end

Class Method Details

.allObject



31
32
33
# File 'lib/barbershop_contestants/competitor.rb', line 31

def self.all
  @@all
end

.create(arg_hash) ⇒ Object



25
26
27
28
29
# File 'lib/barbershop_contestants/competitor.rb', line 25

def self.create(arg_hash)
  competitor = self.new(arg_hash)
  competitor.save
  competitor
end

.fill_find_or_create(arg_hash) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/barbershop_contestants/competitor.rb', line 17

def self.fill_find_or_create(arg_hash)
  if self.all.find { |c| c.name == arg_hash[:name] }
    self.fill(arg_hash)
  else
    self.create(arg_hash)
  end
end

.find_or_create(arg_hash) ⇒ Object



13
14
15
# File 'lib/barbershop_contestants/competitor.rb', line 13

def self.find_or_create(arg_hash)
  self.all.find { |x| x.name == arg_hash[:name] } || self.create(arg_hash)
end

Instance Method Details

#saveObject



9
10
11
# File 'lib/barbershop_contestants/competitor.rb', line 9

def save
  Competitor.all << self
end