Class: Basic101::Arguments
- Inherits:
-
Object
- Object
- Basic101::Arguments
- Defined in:
- lib/basic101/arguments.rb
Instance Attribute Summary collapse
-
#filenames ⇒ Object
readonly
Returns the value of attribute filenames.
-
#randomize ⇒ Object
readonly
Returns the value of attribute randomize.
-
#transcript ⇒ Object
readonly
Returns the value of attribute transcript.
Instance Method Summary collapse
-
#initialize(argv) ⇒ Arguments
constructor
A new instance of Arguments.
Constructor Details
#initialize(argv) ⇒ Arguments
Returns a new instance of Arguments.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/basic101/arguments.rb', line 11 def initialize(argv) @transcript = false @randomize = true OptionParser.new do |opts| opts. << " [PATH]..." opts.on('-t', '--transcript', 'Write transcript of input and output') do |v| @transcript = v end opts.on('--[no-]randomize', 'Randomize random number generator.', 'Default is --randomize') do |v| @randomize = v end end.parse!(argv) @filenames = argv.dup rescue OptionParser::ParseError => e $stderr.puts e exit 1 end |
Instance Attribute Details
#filenames ⇒ Object (readonly)
Returns the value of attribute filenames.
7 8 9 |
# File 'lib/basic101/arguments.rb', line 7 def filenames @filenames end |
#randomize ⇒ Object (readonly)
Returns the value of attribute randomize.
8 9 10 |
# File 'lib/basic101/arguments.rb', line 8 def randomize @randomize end |
#transcript ⇒ Object (readonly)
Returns the value of attribute transcript.
9 10 11 |
# File 'lib/basic101/arguments.rb', line 9 def transcript @transcript end |