Class: Recheck::Optimist::DateOption
- Defined in:
- lib/recheck/vendor/optimist.rb
Overview
Option for dates. Uses Chronic if it exists.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Option
#default, #long, #multi_given, #name, #permitted, #permitted_response, #short
Instance Method Summary collapse
Methods inherited from Option
#array_default?, #callback, create, #desc, #doesnt_need_autogen_short, #educate, #flag?, #format_stdio, #full_description, #initialize, #multi, #multi_arg?, #opts, #opts=, #permitted_type_valid?, #permitted_valid_string, #permitted_value?, register_alias, #required?, #single_arg?, #validate_permitted
Constructor Details
This class inherits a constructor from Recheck::Optimist::Option
Instance Method Details
#parse(paramlist, _neg_given) ⇒ Object
1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 |
# File 'lib/recheck/vendor/optimist.rb', line 1135 def parse(paramlist, _neg_given) paramlist.map do |pg| pg.map do |param| next param if param.is_a?(Date) begin begin require "chronic" time = Chronic.parse(param) rescue LoadError # chronic is not available end time ? Date.new(time.year, time.month, time.day) : Date.parse(param) rescue ArgumentError raise CommandlineError, "option '#{name}' needs a date" end end end end |
#type_format ⇒ Object
1131 1132 1133 |
# File 'lib/recheck/vendor/optimist.rb', line 1131 def type_format "=<date>" end |