Class: Partner
- Inherits:
-
Object
- Object
- Partner
- Defined in:
- lib/partner.rb
Instance Attribute Summary collapse
-
#cost_per_gb ⇒ Object
Returns the value of attribute cost_per_gb.
-
#maximum_size ⇒ Object
Returns the value of attribute maximum_size.
-
#minimum_cost ⇒ Object
Returns the value of attribute minimum_cost.
-
#minimum_size ⇒ Object
Returns the value of attribute minimum_size.
-
#partner_id ⇒ Object
Returns the value of attribute partner_id.
-
#theater_id ⇒ Object
Returns the value of attribute theater_id.
Instance Method Summary collapse
- #calculate_delivery_cost(theatre) ⇒ Object
- #deliverable_size?(delivery_size) ⇒ Boolean
-
#initialize(theater_id, minimum_size, maximum_size, minimum_cost, cost_per_gb, partner_id) ⇒ Partner
constructor
A new instance of Partner.
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_gb ⇒ Object
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_size ⇒ Object
Returns the value of attribute maximum_size.
2 3 4 |
# File 'lib/partner.rb', line 2 def maximum_size @maximum_size end |
#minimum_cost ⇒ Object
Returns the value of attribute minimum_cost.
2 3 4 |
# File 'lib/partner.rb', line 2 def minimum_cost @minimum_cost end |
#minimum_size ⇒ Object
Returns the value of attribute minimum_size.
2 3 4 |
# File 'lib/partner.rb', line 2 def minimum_size @minimum_size end |
#partner_id ⇒ Object
Returns the value of attribute partner_id.
2 3 4 |
# File 'lib/partner.rb', line 2 def partner_id @partner_id end |
#theater_id ⇒ Object
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
13 14 15 |
# File 'lib/partner.rb', line 13 def deliverable_size?(delivery_size) delivery_size.between?(minimum_size, maximum_size) end |