Class: Ptimelog::NamedDate
- Inherits:
-
Object
- Object
- Ptimelog::NamedDate
- Defined in:
- lib/ptimelog/named_date.rb
Overview
Mapping between semantic/relative names and absolute dates
Instance Method Summary collapse
- #date(arg = 'last') ⇒ Object
-
#named_date(date) ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity,Metrics/AbcSize.
Instance Method Details
#date(arg = 'last') ⇒ Object
8 9 10 |
# File 'lib/ptimelog/named_date.rb', line 8 def date(arg = 'last') named_date(arg) || :all end |
#named_date(date) ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity,Metrics/AbcSize
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ptimelog/named_date.rb', line 12 def named_date(date) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/AbcSize case date.to_s when 'yesterday' then yesterday when 'today' then Date.today.to_s when 'last', '' then last_entry.to_s || yesterday when 'mon', 'monday' then previous_weekday('monday') when 'tue', 'tuesday' then previous_weekday('tuesday') when 'wed', 'wednesday' then previous_weekday('wednesday') when 'thu', 'thursday' then previous_weekday('thursday') when 'fri', 'friday' then previous_weekday('friday') when 'sat', 'saturday' then previous_weekday('saturday') when 'sun', 'sunday' then previous_weekday('sunday') when /\d{4}(-\d{2}){2}/ then date.to_s end end |