Sha256: 9e4e291b4c8d4bb2b419a263b2e9becb23fff802687f506f8f7979d65b89186f

Contents?: true

Size: 692 Bytes

Versions: 5

Compression:

Stored size: 692 Bytes

Contents

# holds the data specific to each contest
class Contest
  # now there's text again
  attr_accessor :performances, :year, :city, :type

  @@all = []

  def initialize(arg_hash)
    self.performances = (arg_hash[:performances] || [])
    self.year = arg_hash[:year]
    self.city = arg_hash[:city]
    self.type = arg_hash[:type]
  end

  def save
    Contest.all << self
  end

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

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

  def self.all
    @@all
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
barbershop_contestants-0.3.5 lib/barbershop_contestants/contest.rb
barbershop_contestants-0.3.4 lib/barbershop_contestants/contest.rb
barbershop_contestants-0.3.2 lib/barbershop_contestants/contest.rb
barbershop_contestants-0.3.1 lib/barbershop_contestants/contest.rb
barbershop_contestants-0.3.0 lib/barbershop_contestants/contest.rb