Class: Slop::ArrayOption
Overview
Collect multiple items into a single Array. Support arguments separated by commas or multiple occurences.
Constant Summary
Constants inherited from Option
Instance Attribute Summary
Attributes inherited from Option
#block, #config, #count, #desc, #flags, #value
Instance Method Summary collapse
Methods inherited from Option
#ensure_call, #expects_argument?, #finish, #flag, #help?, #initialize, #key, #null?, #required?, #reset, #suppress_errors?, #tail, #tail?, #to_s, #underscore_flags?
Constructor Details
This class inherits a constructor from Slop::Option
Instance Method Details
#call(value) ⇒ Object
73 74 75 76 77 78 79 80 |
# File 'lib/slop/types.rb', line 73 def call(value) @value ||= [] if delimiter @value.concat value.split(delimiter, limit) else @value << value end end |
#default_value ⇒ Object
82 83 84 |
# File 'lib/slop/types.rb', line 82 def default_value config[:default] || [] end |
#delimiter ⇒ Object
86 87 88 |
# File 'lib/slop/types.rb', line 86 def delimiter config.fetch(:delimiter, ",") end |
#limit ⇒ Object
90 91 92 |
# File 'lib/slop/types.rb', line 90 def limit config[:limit] || 0 end |