Class: OptParseBuilder::OptionalOperandArgument

Inherits:
Argument
  • Object
show all
Includes:
FormatsOperandName, HasValue
Defined in:
lib/opt_parse_builder/optional_operand_argument.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes included from HasValue

#key, #value

Instance Method Summary collapse

Methods included from HasValue

#init_value, #reset

Methods included from FormatsOperandName

#format_operand_name

Methods inherited from Argument

#apply_option, #banner_lines, #key, #reset, #separator_lines, #to_a, #value, #value=

Constructor Details

#initialize(key, default, help_name) ⇒ OptionalOperandArgument

Returns a new instance of OptionalOperandArgument.


7
8
9
10
# File 'lib/opt_parse_builder/optional_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_notationObject


12
13
14
# File 'lib/opt_parse_builder/optional_operand_argument.rb', line 12

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

#optionalObject


20
21
22
# File 'lib/opt_parse_builder/optional_operand_argument.rb', line 20

def optional
  self
end

#requiredObject


24
25
26
# File 'lib/opt_parse_builder/optional_operand_argument.rb', line 24

def required
  RequiredOperandArgument.new(@key, @default, @help_name)
end

#shift_operand(argv) ⇒ Object


16
17
18
# File 'lib/opt_parse_builder/optional_operand_argument.rb', line 16

def shift_operand(argv)
  @value = argv.shift
end