Class: Production
- Inherits:
-
Object
- Object
- Production
- Extended by:
- Shared::Findable
- Defined in:
- lib/Theatre_Explorer/production.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#details ⇒ Object
Returns the value of attribute details.
-
#label ⇒ Object
Returns the value of attribute label.
-
#show ⇒ Object
Returns the value of attribute show.
-
#year ⇒ Object
Returns the value of attribute year.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Production
constructor
A new instance of Production.
- #join_show(show_label) ⇒ Object
- #join_year(year_label) ⇒ Object
- #print ⇒ Object
Methods included from Shared::Findable
Constructor Details
#initialize(attributes) ⇒ Production
Returns a new instance of Production.
6 7 8 9 10 11 12 13 14 |
# 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 |
Instance Attribute Details
#details ⇒ Object
Returns the value of attribute details.
2 3 4 |
# File 'lib/Theatre_Explorer/production.rb', line 2 def details @details end |
#label ⇒ Object
Returns the value of attribute label.
2 3 4 |
# File 'lib/Theatre_Explorer/production.rb', line 2 def label @label end |
#show ⇒ Object
Returns the value of attribute show.
2 3 4 |
# File 'lib/Theatre_Explorer/production.rb', line 2 def show @show end |
#year ⇒ Object
Returns the value of attribute year.
2 3 4 |
# File 'lib/Theatre_Explorer/production.rb', line 2 def year @year end |
Class Method Details
.all ⇒ Object
16 17 18 |
# File 'lib/Theatre_Explorer/production.rb', line 16 def self.all @@all end |
Instance Method Details
#join_show(show_label) ⇒ Object
27 28 29 30 31 32 |
# 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) ⇒ Object
20 21 22 23 24 25 |
# 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 ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# 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 |