Class: Theatre

Inherits:
Object
  • Object
show all
Defined in:
lib/theatre.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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.deliverable_options = [] 
end

Instance Attribute Details

#deliverable_optionsObject

Returns the value of attribute deliverable_options.



2
3
4
# File 'lib/theatre.rb', line 2

def deliverable_options
  @deliverable_options
end

#delivery_idObject

Returns the value of attribute delivery_id.



2
3
4
# File 'lib/theatre.rb', line 2

def delivery_id
  @delivery_id
end

#delivery_sizeObject

Returns the value of attribute delivery_size.



2
3
4
# File 'lib/theatre.rb', line 2

def delivery_size
  @delivery_size
end

#theater_idObject

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_costObject



11
12
13
14
# File 'lib/theatre.rb', line 11

def filter_by_cost
  lowest = self.deliverable_options.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 set_deliverable_options(partners)
available_partners = filtered_partners(partners)
available_partners.each do |partner|
	self.deliverable_options << Deliverable.new(self.delivery_id, true, partner.partner_id, partner.calculate_delivery_cost(self), self.delivery_size)
end		
end