Class: Chronik::Label
- Inherits:
-
Object
- Object
- Chronik::Label
- Defined in:
- lib/chronik/label.rb
Overview
The class of days.
Instance Method Summary collapse
-
#holidays(range = (Date.today..Date.today.next_month)) ⇒ Object
Special days which are represented by this label.
-
#initialize(text) ⇒ Label
constructor
A new instance of Label.
-
#weekdays ⇒ Object
Day(s) of a week (Sunday is 0).
Constructor Details
Instance Method Details
#holidays(range = (Date.today..Date.today.next_month)) ⇒ Object
Special days which are represented by this label. Those are probably one in a year holidays like Christmas.
range - [Range]:
Returns an Array of Dates.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/chronik/label.rb', line 16 def holidays(range=(Date.today..Date.today.next_month)) output = [] @tokens.each do |token| if ALL_HOLIDAYS.include?(token) return HOLIDAYS.values.map do |dates| dates.call(range) end.flatten.uniq end HOLIDAYS.each_pair do |labels,dates| if labels.include?(token) output.concat(dates.call(range)) end end end output end |
#weekdays ⇒ Object
Day(s) of a week (Sunday is 0). Also range of days, like weekend.
Returns an Array of Integers.
36 37 38 39 40 41 42 43 |
# File 'lib/chronik/label.rb', line 36 def weekdays @tokens.each do |token| WEEKDAYS.each_pair do |labels,wdays| return wdays if labels.include?(token) end end [] end |