summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJoe Gracyk <jgracyk@squareup.com>2021-05-10 14:06:35 -0700
committerJoe Gracyk <jgracyk@squareup.com>2021-05-10 14:06:35 -0700
commit6e6ed91d0d5c3e2197f0207894a01226446759de (patch)
tree87095784fdb633dc656ffe78f55f344775ed2189 /lib
parent3cbd0e9dfaa6804d6f46fbbec08155a680193cd7 (diff)
downloadslop-6e6ed91d0d5c3e2197f0207894a01226446759de.tar.gz
Add symbols to option types
Diffstat (limited to 'lib')
-rw-r--r--lib/slop/types.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/slop/types.rb b/lib/slop/types.rb
index c53319c..4ccd42e 100644
--- a/lib/slop/types.rb
+++ b/lib/slop/types.rb
@@ -6,6 +6,13 @@ module Slop
end
end
+ # Cast the option argument to a symbol.
+ class SymbolOption < Option
+ def call(value)
+ value.to_sym
+ end
+ end
+
# Cast the option argument to true or false.
# Override default_value to default to false instead of nil.
# This option type does not expect an argument. However, the API