class Chorus

Attributes

director[RW]
hometown[RW]

Public Class Methods

all() click to toggle source
# File lib/barbershop_contestants/competitor.rb, line 86
def self.all
  @@all.find_all { |c| c.type == "chorus" }
end
new(arg_hash) click to toggle source
# 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

Public Instance Methods

current_director() click to toggle source
# 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) click to toggle source
# 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