Class: Roxbury::BusinessDay
- Inherits:
-
Object
- Object
- Roxbury::BusinessDay
- Defined in:
- lib/roxbury/business_day.rb
Overview
Wraps a specific date with its working hours schedule
Instance Method Summary collapse
- #at_beginning ⇒ Object
- #at_end ⇒ Object
- #ends_before?(timestamp) ⇒ Boolean
- #include?(timestamp) ⇒ Boolean
-
#initialize(date, working_hours) ⇒ BusinessDay
constructor
A new instance of BusinessDay.
- #number_of_working_hours(*args) ⇒ Object
- #same_day?(timestamp) ⇒ Boolean
- #starts_after?(timestamp) ⇒ Boolean
Constructor Details
#initialize(date, working_hours) ⇒ BusinessDay
Returns a new instance of BusinessDay.
4 5 6 7 |
# File 'lib/roxbury/business_day.rb', line 4 def initialize date, working_hours @date = date @working_hours = working_hours end |
Instance Method Details
#at_beginning ⇒ Object
29 30 31 |
# File 'lib/roxbury/business_day.rb', line 29 def at_beginning @working_hours.at_beginning @date end |
#at_end ⇒ Object
33 34 35 |
# File 'lib/roxbury/business_day.rb', line 33 def at_end @working_hours.at_end @date end |
#ends_before?(timestamp) ⇒ Boolean
25 26 27 |
# File 'lib/roxbury/business_day.rb', line 25 def ends_before? same_day?() && @working_hours.ends_before?() end |
#include?(timestamp) ⇒ Boolean
17 18 19 |
# File 'lib/roxbury/business_day.rb', line 17 def include? same_day?() && @working_hours.include?() end |
#number_of_working_hours(*args) ⇒ Object
9 10 11 |
# File 'lib/roxbury/business_day.rb', line 9 def number_of_working_hours *args @working_hours.quantity *args end |
#same_day?(timestamp) ⇒ Boolean
13 14 15 |
# File 'lib/roxbury/business_day.rb', line 13 def same_day? .to_date == @date.to_date end |
#starts_after?(timestamp) ⇒ Boolean
21 22 23 |
# File 'lib/roxbury/business_day.rb', line 21 def starts_after? same_day?() && @working_hours.starts_after?() end |