Class: OptParseBuilder::OptionArgument
- Includes:
- HasValue
- Defined in:
- lib/opt_parse_builder/option_argument.rb
Overview
:nodoc:
Constant Summary collapse
- DEFAULT_HANDLER =
->(argument, value) { argument.value = value }
Instance Attribute Summary
Attributes included from HasValue
Instance Method Summary collapse
- #apply_option(op) ⇒ Object
-
#initialize(key, default, on, handler) ⇒ OptionArgument
constructor
A new instance of OptionArgument.
Methods included from HasValue
Methods inherited from Argument
#banner_lines, #footer_lines, #key, #operand_notation, #optional, #required, #reset, #separator_lines, #shift_operand, #to_a, #value, #value=
Constructor Details
#initialize(key, default, on, handler) ⇒ OptionArgument
8 9 10 11 12 |
# File 'lib/opt_parse_builder/option_argument.rb', line 8 def initialize(key, default, on, handler) init_value(key, default) @on = on @handler = handler || DEFAULT_HANDLER end |
Instance Method Details
#apply_option(op) ⇒ Object
14 15 16 17 18 |
# File 'lib/opt_parse_builder/option_argument.rb', line 14 def apply_option(op) op.on(*edited_on) do |value| @handler.call(self, value) end end |