Sha256: 059c38e1a0d5bdaf2b0ce097aac3d03d884a9685255ed055b7fa6c9e0adef348

Contents?: true

Size: 755 Bytes

Versions: 3

Compression:

Stored size: 755 Bytes

Contents

# frozen_string_literal: true

module Basic101

  class Arguments

    attr_reader :filenames
    attr_reader :randomize
    attr_reader :transcript

    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

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
basic101-1.0.2 lib/basic101/arguments.rb
basic101-1.0.1 lib/basic101/arguments.rb
basic101-1.0.0 lib/basic101/arguments.rb