Class: Eg::Book::LateReturns

Inherits:
Object
  • Object
show all
Defined in:
lib/eg/book/rent/calculate_late_hours.rb

Overview

System under test

Instance Method Summary collapse

Constructor Details

#initialize(count_grace) ⇒ LateReturns



23
24
25
# File 'lib/eg/book/rent/calculate_late_hours.rb', line 23

def initialize count_grace
  @count_grace = count_grace
end

Instance Method Details

#extra_hours(hours_late, grace, high_demand) ⇒ Object



26
27
28
29
30
31
# File 'lib/eg/book/rent/calculate_late_hours.rb', line 26

def extra_hours hours_late, grace, high_demand
 return 0 if hours_late < 1
 hours = @count_grace ? hours_late : (hours_late - grace)
 return 0 if hours.zero?
 high_demand + hours
end