Class: Theatre
- Inherits:
-
Object
- Object
- Theatre
- Defined in:
- lib/theatre.rb
Instance Attribute Summary collapse
-
#deliverable_options ⇒ Object
Returns the value of attribute deliverable_options.
-
#delivery_id ⇒ Object
Returns the value of attribute delivery_id.
-
#delivery_size ⇒ Object
Returns the value of attribute delivery_size.
-
#theater_id ⇒ Object
Returns the value of attribute theater_id.
Instance Method Summary collapse
- #filter_by_cost ⇒ Object
-
#initialize(delivery_id, delivery_size, theater_id) ⇒ Theatre
constructor
A new instance of Theatre.
- #set_deliverable_options(partners) ⇒ Object
Constructor Details
#initialize(delivery_id, delivery_size, theater_id) ⇒ Theatre
Returns a new instance of Theatre.
4 5 6 7 8 9 |
# File 'lib/theatre.rb', line 4 def initialize(delivery_id, delivery_size, theater_id) self.delivery_id = delivery_id self.delivery_size = delivery_size self.theater_id = theater_id self. = [] end |
Instance Attribute Details
#deliverable_options ⇒ Object
Returns the value of attribute deliverable_options.
2 3 4 |
# File 'lib/theatre.rb', line 2 def @deliverable_options end |
#delivery_id ⇒ Object
Returns the value of attribute delivery_id.
2 3 4 |
# File 'lib/theatre.rb', line 2 def delivery_id @delivery_id end |
#delivery_size ⇒ Object
Returns the value of attribute delivery_size.
2 3 4 |
# File 'lib/theatre.rb', line 2 def delivery_size @delivery_size end |
#theater_id ⇒ Object
Returns the value of attribute theater_id.
2 3 4 |
# File 'lib/theatre.rb', line 2 def theater_id @theater_id end |
Instance Method Details
#filter_by_cost ⇒ Object
11 12 13 14 |
# File 'lib/theatre.rb', line 11 def filter_by_cost lowest = self..min_by{ |opt| opt.delivery_cost } lowest.nil? ? Deliverable.new(self.delivery_id, false) : lowest end |
#set_deliverable_options(partners) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/theatre.rb', line 16 def (partners) available_partners = filtered_partners(partners) available_partners.each do |partner| self. << Deliverable.new(self.delivery_id, true, partner.partner_id, partner.calculate_delivery_cost(self), self.delivery_size) end end |