Sha256: ece4016171620431db880e8c361c2279642ce5fbe99db908d2b63eea37d3db94

Contents?: true

Size: 623 Bytes

Versions: 1

Compression:

Stored size: 623 Bytes

Contents

module OptParseBuilder
  class RequiredOperandArgument < Argument # :nodoc:

    include FormatsOperandName
    include HasValue

    def initialize(key, default, help_name)
      init_value(key, default)
      @help_name = help_name || key
    end

    def operand_notation
      "<#{format_operand_name(@help_name)}>"
    end

    def shift_operand(argv)
      @value = argv.shift
      unless @value
        raise OptionParser::MissingArgument, operand_notation
      end
    end

    def optional
      OptionalOperandArgument.new(@key, @default, @help_name)
    end

    def required
      self
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opt_parse_builder-0.1.0 lib/opt_parse_builder/required_operand_argument.rb