Class: WorkingCalendar::WeekDay
- Inherits:
-
Object
- Object
- WorkingCalendar::WeekDay
- Includes:
- CastHelper
- Defined in:
- lib/working_calendar/week_day.rb
Constant Summary
Constants included from CastHelper
Instance Attribute Summary collapse
-
#day_name ⇒ Object
readonly
Returns the value of attribute day_name.
-
#hours_ranges ⇒ Object
readonly
Returns the value of attribute hours_ranges.
Instance Method Summary collapse
- #include?(time) ⇒ Boolean
-
#initialize(day_name, hours_ranges) ⇒ WeekDay
constructor
A new instance of WeekDay.
- #to_s ⇒ Object (also: #inspect)
Methods included from CastHelper
#cast_date, #cast_day_name, #cast_hours_ranges
Constructor Details
#initialize(day_name, hours_ranges) ⇒ WeekDay
Returns a new instance of WeekDay.
8 9 10 11 |
# File 'lib/working_calendar/week_day.rb', line 8 def initialize(day_name, hours_ranges) @day_name = cast_day_name day_name @hours_ranges = cast_hours_ranges hours_ranges end |
Instance Attribute Details
#day_name ⇒ Object (readonly)
Returns the value of attribute day_name.
6 7 8 |
# File 'lib/working_calendar/week_day.rb', line 6 def day_name @day_name end |
#hours_ranges ⇒ Object (readonly)
Returns the value of attribute hours_ranges.
6 7 8 |
# File 'lib/working_calendar/week_day.rb', line 6 def hours_ranges @hours_ranges end |
Instance Method Details
#include?(time) ⇒ Boolean
13 14 15 16 |
# File 'lib/working_calendar/week_day.rb', line 13 def include?(time) hms = Timing::HourMinutesSeconds.new time.hour, time.min, time.sec time.public_send("#{day_name}?") && hours_ranges.any? { |from, to| hms.between? from, to } end |
#to_s ⇒ Object Also known as: inspect
18 19 20 |
# File 'lib/working_calendar/week_day.rb', line 18 def to_s "#{day_name.capitalize} #{hours_ranges}" end |