Class: Matheus::DateOfLast
- Defined in:
- lib/matheus/date_of_last.rb
Overview
Usage:
$ date-of-last monday
2022-01-24
Instance Method Summary collapse
Methods inherited from Command
Methods included from StringFormat
Methods included from Result::Methods
Instance Method Details
#call(args) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/matheus/date_of_last.rb', line 10 def call(args) day_name = args[0].to_s target_wday = wday_for(day_name) or return Failure("invalid day name: #{day_name.inspect}") date = Enumerator.produce(Date.today - 1, &:prev_day).find { _1.wday == target_wday } puts date end |