Class: OptParseBuilder::RequiredOperandArgument
Overview
Instance Attribute Summary
Attributes included from HasValue
#key, #value
Instance Method Summary
collapse
Methods included from HasValue
#init_value, #reset
#format_operand_name
Methods inherited from Argument
#apply_option, #banner_lines, #footer_lines, #key, #reset, #separator_lines, #to_a, #value, #value=
Constructor Details
Returns a new instance of RequiredOperandArgument.
7
8
9
10
|
# File 'lib/opt_parse_builder/required_operand_argument.rb', line 7
def initialize(key, default, help_name)
init_value(key, default)
@help_name = help_name || key
end
|
Instance Method Details
#operand_notation ⇒ Object
12
13
14
|
# File 'lib/opt_parse_builder/required_operand_argument.rb', line 12
def operand_notation
"<#{format_operand_name(@help_name)}>"
end
|
#optional ⇒ Object
23
24
25
|
# File 'lib/opt_parse_builder/required_operand_argument.rb', line 23
def optional
OptionalOperandArgument.new(@key, @default, @help_name)
end
|
#required ⇒ Object
27
28
29
|
# File 'lib/opt_parse_builder/required_operand_argument.rb', line 27
def required
self
end
|
#shift_operand(argv) ⇒ Object
16
17
18
19
20
21
|
# File 'lib/opt_parse_builder/required_operand_argument.rb', line 16
def shift_operand(argv)
@value = argv.shift
unless @value
raise OptionParser::MissingArgument, operand_notation
end
end
|