Class: Partner

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(theater_id, minimum_size, maximum_size, minimum_cost, cost_per_gb, partner_id) ⇒ Partner

Returns a new instance of Partner.



4
5
6
7
8
9
10
11
# File 'lib/partner.rb', line 4

def initialize(theater_id, minimum_size, maximum_size, minimum_cost, cost_per_gb, partner_id)
self.theater_id = theater_id
self.minimum_size = minimum_size
self.maximum_size = maximum_size
self.minimum_cost = minimum_cost
self.cost_per_gb = cost_per_gb
self.partner_id = partner_id
end

Instance Attribute Details

#cost_per_gbObject

Returns the value of attribute cost_per_gb.



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

def cost_per_gb
  @cost_per_gb
end

#maximum_sizeObject

Returns the value of attribute maximum_size.



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

def maximum_size
  @maximum_size
end

#minimum_costObject

Returns the value of attribute minimum_cost.



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

def minimum_cost
  @minimum_cost
end

#minimum_sizeObject

Returns the value of attribute minimum_size.



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

def minimum_size
  @minimum_size
end

#partner_idObject

Returns the value of attribute partner_id.



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

def partner_id
  @partner_id
end

#theater_idObject

Returns the value of attribute theater_id.



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

def theater_id
  @theater_id
end

Instance Method Details

#calculate_delivery_cost(theatre) ⇒ Object



17
18
19
20
# File 'lib/partner.rb', line 17

def calculate_delivery_cost(theatre)
  calculated_cost = theatre.delivery_size * self.cost_per_gb
calculated_cost < self.minimum_cost ? self.minimum_cost : calculated_cost
end

#deliverable_size?(delivery_size) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/partner.rb', line 13

def deliverable_size?(delivery_size)
  delivery_size.between?(minimum_size, maximum_size)
end