Class: Chorus
- Inherits:
-
Competitor
- Object
- Competitor
- Chorus
- Defined in:
- lib/barbershop_contestants/competitor.rb
Instance Attribute Summary collapse
-
#director ⇒ Object
Returns the value of attribute director.
-
#hometown ⇒ Object
Returns the value of attribute hometown.
Attributes inherited from Competitor
#district, #name, #performances, #type
Class Method Summary collapse
Instance Method Summary collapse
- #current_director ⇒ Object
- #format_hometown_and_district(hometown_and_district) ⇒ Object
-
#initialize(arg_hash) ⇒ Chorus
constructor
A new instance of Chorus.
Methods inherited from Competitor
create, fill_find_or_create, find_or_create, #save
Constructor Details
#initialize(arg_hash) ⇒ Chorus
Returns a new instance of Chorus.
64 65 66 67 68 69 70 71 |
# File 'lib/barbershop_contestants/competitor.rb', line 64 def initialize(arg_hash) self.name = arg_hash[:name] self.type = 'chorus' self.district = arg_hash[:district] format_hometown_and_district(arg_hash[:hometown_and_district]) self.performances = (arg_hash[:performances] || []) self.director = arg_hash[:director] end |
Instance Attribute Details
#director ⇒ Object
Returns the value of attribute director.
62 63 64 |
# File 'lib/barbershop_contestants/competitor.rb', line 62 def director @director end |
#hometown ⇒ Object
Returns the value of attribute hometown.
62 63 64 |
# File 'lib/barbershop_contestants/competitor.rb', line 62 def hometown @hometown end |
Class Method Details
.all ⇒ Object
86 87 88 |
# File 'lib/barbershop_contestants/competitor.rb', line 86 def self.all @@all.find_all { |c| c.type == "chorus" } end |
Instance Method Details
#current_director ⇒ Object
73 74 75 |
# File 'lib/barbershop_contestants/competitor.rb', line 73 def current_director performances.max { |p| p.year.to_i }.director end |
#format_hometown_and_district(hometown_and_district) ⇒ Object
77 78 79 80 81 82 83 84 |
# File 'lib/barbershop_contestants/competitor.rb', line 77 def format_hometown_and_district(hometown_and_district) # TODO: plug this logic in if hometown_and_district h_d_match = /(?<h>.*) \((?<d>.*)\)/.match(hometown_and_district) self.hometown = h_d_match[:h] self.district = h_d_match[:d] end end |