summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLee Jarvis <ljjarvis@gmail.com>2014-12-30 15:04:26 +0000
committerLee Jarvis <ljjarvis@gmail.com>2014-12-30 15:04:26 +0000
commitd6b91418f9cb8aa141ecb1f4c00c5f06ae293b67 (patch)
tree7fb8f91ce5bfde32772b21a8f1e82411ad5175ef /lib
parent2ae81e5ced1bd5af3cd891a04e1750a6019e114b (diff)
downloadslop-d6b91418f9cb8aa141ecb1f4c00c5f06ae293b67.tar.gz
Support a limit config to ArrayOption
Diffstat (limited to 'lib')
-rw-r--r--lib/slop/types.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/slop/types.rb b/lib/slop/types.rb
index 8bc7f65..df67aee 100644
--- a/lib/slop/types.rb
+++ b/lib/slop/types.rb
@@ -45,7 +45,7 @@ module Slop
class ArrayOption < Option
def call(value)
@value ||= []
- @value.concat value.split(delimiter)
+ @value.concat value.split(delimiter, limit)
end
def default_value
@@ -55,6 +55,10 @@ module Slop
def delimiter
config[:delimiter] || ","
end
+
+ def limit
+ config[:limit] || 0
+ end
end
# An option that discards the return value, inherits from Bool