Class: DateInterval::Filter::Weekday
- Defined in:
- lib/date_interval/filter/weekday.rb
Constant Summary collapse
- WEEKDAYS =
%w[sunday monday tuesday wednesday thursday friday saturday]
Instance Attribute Summary collapse
-
#day ⇒ Object
readonly
Returns the value of attribute day.
-
#operator ⇒ Object
readonly
Returns the value of attribute operator.
-
#wday ⇒ Object
readonly
Returns the value of attribute wday.
Instance Method Summary collapse
- #filter(dates) ⇒ Object
-
#initialize(day, operator) ⇒ Weekday
constructor
A new instance of Weekday.
Methods inherited from Operator
Constructor Details
#initialize(day, operator) ⇒ Weekday
Returns a new instance of Weekday.
8 9 10 11 12 |
# File 'lib/date_interval/filter/weekday.rb', line 8 def initialize(day, operator) @day = day @wday = WEEKDAYS.index(day) @operator = operator end |
Instance Attribute Details
#day ⇒ Object (readonly)
Returns the value of attribute day.
4 5 6 |
# File 'lib/date_interval/filter/weekday.rb', line 4 def day @day end |
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
4 5 6 |
# File 'lib/date_interval/filter/weekday.rb', line 4 def operator @operator end |
#wday ⇒ Object (readonly)
Returns the value of attribute wday.
4 5 6 |
# File 'lib/date_interval/filter/weekday.rb', line 4 def wday @wday end |
Instance Method Details
#filter(dates) ⇒ Object
14 15 16 |
# File 'lib/date_interval/filter/weekday.rb', line 14 def filter(dates) dates.select {|date| date.wday == wday } end |