Class: Basic101::Arguments

Inherits:
Object
  • Object
show all
Defined in:
lib/basic101/arguments.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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.banner << " [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

#filenamesObject (readonly)

Returns the value of attribute filenames.



7
8
9
# File 'lib/basic101/arguments.rb', line 7

def filenames
  @filenames
end

#randomizeObject (readonly)

Returns the value of attribute randomize.



8
9
10
# File 'lib/basic101/arguments.rb', line 8

def randomize
  @randomize
end

#transcriptObject (readonly)

Returns the value of attribute transcript.



9
10
11
# File 'lib/basic101/arguments.rb', line 9

def transcript
  @transcript
end