Class: QuickAndRuby::Date::DateTimeArgs
- Inherits:
-
Object
- Object
- QuickAndRuby::Date::DateTimeArgs
- Defined in:
- lib/quick_and_ruby/date/date_time_args.rb
Overview
argv parser for datetime utility
parsing example:
- datetime -z <zone> -i <incr> -f "<format>" <from>|now <to>|now
- datetime -z <zone> -i <incr> -f "<format>" <from>|now
Constant Summary collapse
- DEFAULT_FORMAT =
'%Y-%m-%dT%H:%M:%S.%3NZ'
- DEFAULT_INCR =
'1d'
- DEFAULT_ZONE =
DateTime.now.zone
Instance Attribute Summary collapse
-
#date_begin ⇒ Object
readonly
Returns the value of attribute date_begin.
-
#date_end ⇒ Object
readonly
Returns the value of attribute date_end.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#incr ⇒ Object
readonly
Returns the value of attribute incr.
-
#zone ⇒ Object
readonly
Returns the value of attribute zone.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(date_begin: DateTime.now, date_end: nil, incr: DEFAULT_INCR, format: DEFAULT_FORMAT, zone: DEFAULT_ZONE) ⇒ DateTimeArgs
constructor
A new instance of DateTimeArgs.
- #want_incr? ⇒ Boolean
- #want_range? ⇒ Boolean
Constructor Details
#initialize(date_begin: DateTime.now, date_end: nil, incr: DEFAULT_INCR, format: DEFAULT_FORMAT, zone: DEFAULT_ZONE) ⇒ DateTimeArgs
Returns a new instance of DateTimeArgs.
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/quick_and_ruby/date/date_time_args.rb', line 21 def initialize(date_begin: DateTime.now, date_end: nil, incr: DEFAULT_INCR, format: DEFAULT_FORMAT, zone: DEFAULT_ZONE) @date_begin = date_begin @date_end = date_end @incr = incr @format = format @zone = zone end |
Instance Attribute Details
#date_begin ⇒ Object (readonly)
Returns the value of attribute date_begin.
19 20 21 |
# File 'lib/quick_and_ruby/date/date_time_args.rb', line 19 def date_begin @date_begin end |
#date_end ⇒ Object (readonly)
Returns the value of attribute date_end.
19 20 21 |
# File 'lib/quick_and_ruby/date/date_time_args.rb', line 19 def date_end @date_end end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
19 20 21 |
# File 'lib/quick_and_ruby/date/date_time_args.rb', line 19 def format @format end |
#incr ⇒ Object (readonly)
Returns the value of attribute incr.
19 20 21 |
# File 'lib/quick_and_ruby/date/date_time_args.rb', line 19 def incr @incr end |
#zone ⇒ Object (readonly)
Returns the value of attribute zone.
19 20 21 |
# File 'lib/quick_and_ruby/date/date_time_args.rb', line 19 def zone @zone end |
Class Method Details
.load(argv = ARGV) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/quick_and_ruby/date/date_time_args.rb', line 41 def load(argv = ARGV) = new parser().parse!(argv.clone) puts end |
Instance Method Details
#want_incr? ⇒ Boolean
36 37 38 |
# File 'lib/quick_and_ruby/date/date_time_args.rb', line 36 def want_incr? date_begin && !date_end end |
#want_range? ⇒ Boolean
32 33 34 |
# File 'lib/quick_and_ruby/date/date_time_args.rb', line 32 def want_range? date_begin && date_end end |