summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLaurent Arnoud <laurent@spkdev.net>2015-05-17 16:57:18 +0200
committerLaurent Arnoud <laurent@spkdev.net>2015-05-17 16:57:18 +0200
commite7521a65b01560ac997ccb907d33e4b3795533a7 (patch)
tree3bfe8e7cef6c792ebfc0e977b8af34c1ef18b4e8 /lib
parent4078a1bcfa731fe0f15e3e7d2d4bcf0ac312d435 (diff)
downloadslop-e7521a65b01560ac997ccb907d33e4b3795533a7.tar.gz
Added support for Regexp
Used to work on 3.6 See https://github.com/leejarvis/slop/commit/e2775e27d866ba85f6b6bf50536135ee4e93c93e
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 df67aee..ad7461c 100644
--- a/lib/slop/types.rb
+++ b/lib/slop/types.rb
@@ -61,6 +61,13 @@ module Slop
end
end
+ # Cast the option argument to a Regexp.
+ class RegexpOption < Option
+ def call(value)
+ Regexp.new(value)
+ end
+ end
+
# An option that discards the return value, inherits from Bool
# since it does not expect an argument.
class NullOption < BoolOption