class Production
Attributes
details[RW]
label[RW]
show[RW]
year[RW]
Public Class Methods
all()
click to toggle source
# File lib/Theatre_Explorer/production.rb, line 16 def self.all @@all end
new(attributes)
click to toggle source
# File lib/Theatre_Explorer/production.rb, line 6 def initialize(attributes) unless Production.find(attributes["label"]) @label = label attributes.each {|k,v| self.send("#{k}=", v)} join_year(year) if year join_show(show) if show @@all << self end end
Public Instance Methods
join_show(show_label)
click to toggle source
# File lib/Theatre_Explorer/production.rb, line 27 def join_show(show_label) show = Show.find_or_create(show_label) show.type = details["Show type"] self.show = show show.productions << self end
join_year(year_label)
click to toggle source
# File lib/Theatre_Explorer/production.rb, line 20 def join_year(year_label) year_label = Time.now.year.to_s if year_label == "" year = Year.find_or_create(year_label) self.year = year year.productions << self end
print()
click to toggle source
# File lib/Theatre_Explorer/production.rb, line 34 def print puts "========================" puts "#{label}" puts "========================" puts "Show type: #{details["Show type"]}" if details["summary"] puts "" puts "Summary: \t #{details["summary"]}\n" puts "" else puts "" puts "Summary: Not available for this production\n" puts "" end details.each do |k,v| puts "#{k} \t #{v}" unless k == "summary" || k == "Show type" end end