Class: Vito::CommandLine::Options
- Inherits:
-
Object
- Object
- Vito::CommandLine::Options
- Includes:
- DocumentFlags
- Defined in:
- lib/vito/command_line/options.rb
Instance Method Summary collapse
- #available_options ⇒ Object
- #file ⇒ Object
- #help ⇒ Object
-
#initialize(argv) ⇒ Options
constructor
A new instance of Options.
Methods included from DocumentFlags
Constructor Details
#initialize(argv) ⇒ Options
Returns a new instance of Options.
8 9 10 |
# File 'lib/vito/command_line/options.rb', line 8 def initialize(argv) @argv = argv end |
Instance Method Details
#available_options ⇒ Object
26 27 28 29 30 |
# File 'lib/vito/command_line/options.rb', line 26 def flags = self.class.flags descriptions = self.class.descriptions flags.each_with_index.map { |flag, index| [flag, descriptions[index]] } end |
#file ⇒ Object
14 15 16 17 18 |
# File 'lib/vito/command_line/options.rb', line 14 def file file = nil argv.each_with_index { |value, index| file = argv[index+1] if file?(value) } file end |
#help ⇒ Object
22 23 24 |
# File 'lib/vito/command_line/options.rb', line 22 def help argv.any? { |a| ["-h", "--help"].include?(a) } end |