Class: DayFinder
- Inherits:
-
Object
- Object
- DayFinder
- Defined in:
- lib/day_finder.rb
Instance Method Summary collapse
-
#adjusted_week_date(week_day) ⇒ Object
Adjusts the week date for the -g parameter.
-
#find_week_day(week_day) ⇒ Object
finds the weekday and validates it.
-
#initialize ⇒ DayFinder
constructor
A new instance of DayFinder.
-
#validate_week_day(week_day) ⇒ Object
Validates the weekday to be within the week.
Constructor Details
#initialize ⇒ DayFinder
Returns a new instance of DayFinder.
2 3 |
# File 'lib/day_finder.rb', line 2 def initialize end |
Instance Method Details
#adjusted_week_date(week_day) ⇒ Object
Adjusts the week date for the -g parameter
16 17 18 19 20 |
# File 'lib/day_finder.rb', line 16 def adjusted_week_date(week_day) today = Date.today.cwday difference = (today - week_day) Date.today - difference end |
#find_week_day(week_day) ⇒ Object
finds the weekday and validates it
6 7 8 |
# File 'lib/day_finder.rb', line 6 def find_week_day(week_day) week_day==0 ? Date.today.cwday : validate_week_day(week_day) end |
#validate_week_day(week_day) ⇒ Object
Validates the weekday to be within the week
11 12 13 |
# File 'lib/day_finder.rb', line 11 def validate_week_day(week_day) (1..7).cover?(week_day) ? week_day : invalid_week_day end |