Class: AIRAC::Executable
- Inherits:
-
Object
- Object
- AIRAC::Executable
- Defined in:
- lib/airac/executable.rb
Overview
Executable instantiated by the console tools
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize ⇒ Executable
constructor
A new instance of Executable.
- #run ⇒ Object
Constructor Details
#initialize ⇒ Executable
Returns a new instance of Executable.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/airac/executable.rb', line 7 def initialize @options = { format: nil, offset: 0 } OptionParser.new do |o| o. = <<~END Calculate AIRAC cycle from four digit ID or date within (default: today). Usage: #{File.basename($0)} [options] [cycle] END o.on('-f', '--format TEMPLATE', String, "Template for strftime with %i for cycle ID") { @options[:format] = _1 } o.on('-o', '--offset INTEGER', Integer, "Offset by this many cycles") { @options[:offset] = _1.to_i } o.on('-A', '--about', 'show author/license information and exit') { about } o.on('-V', '--version', 'show version and exit') { version } end.parse! @options[:raw_cycle] = ARGV.shift || Date.today end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/airac/executable.rb', line 5 def @options end |