Class: Achoo::UI::OptionallyRangedDateChooser

Inherits:
DateChooser
  • Object
show all
Defined in:
lib/achoo/ui/optionally_ranged_date_chooser.rb

Constant Summary

Constants inherited from DateChooser

DateChooser::FORMAT, DateChooser::PROMPT

Instance Method Summary collapse

Methods inherited from DateChooser

#choose, #parse_date

Instance Method Details

#parse_date_range(date_range_str) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/achoo/ui/optionally_ranged_date_chooser.rb', line 7

def parse_date_range(date_range_str)
  start_date_str, finish_date_str = *date_range_str.split('->')
  start_date = parse_date(start_date_str.strip)
  finish_date = parse_date(finish_date_str.strip, start_date)
  
  if start_date >= finish_date
    raise ArgumentError.new('Invalid date range')
  end
  
  [start_date, finish_date]
end