Sha256: ea4315d3af5b2add712c04d5ac98bfcc5a7eac08885e9e397a231d86e17d50a6
Contents?: true
Size: 615 Bytes
Versions: 1
Compression:
Stored size: 615 Bytes
Contents
module OptParseBuilder class OptionArgument < Argument # :nodoc: include HasValue DEFAULT_HANDLER = ->(argument, value) { argument.value = value } def initialize(key, default, on, handler) init_value(key, default) @on = on @handler = handler || DEFAULT_HANDLER end def apply_option(op) op.on(*edited_on) do |value| @handler.call(self, value) end end private def edited_on @on.map do |s| if s.respond_to?(:gsub!) s.gsub(/_DEFAULT_/, @default.to_s) else s end end 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/option_argument.rb |