Module: ActiveSupport::CoreExtensions::Date::Calculations
- Included in:
- Date
- Defined in:
- lib/weekdays.rb
Overview
Enables the use of time calculations within Date itself
Instance Method Summary collapse
-
#weekday? ⇒ Boolean
Tells whether the Date object is a weekday.
-
#weekdays_until(date) ⇒ Object
Returns the number of weekdays until a future Date.
Instance Method Details
#weekday? ⇒ Boolean
Tells whether the Date object is a weekday
7 8 9 |
# File 'lib/weekdays.rb', line 7 def weekday? (1..5).include?(wday) end |
#weekdays_until(date) ⇒ Object
Returns the number of weekdays until a future Date
12 13 14 15 |
# File 'lib/weekdays.rb', line 12 def weekdays_until(date) return 0 if date <= self (self...date).select{|day| day.weekday?}.size end |