diff options
Diffstat (limited to 'lib/slop/types.rb')
-rw-r--r-- | lib/slop/types.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/slop/types.rb b/lib/slop/types.rb index 4cd6136..c53319c 100644 --- a/lib/slop/types.rb +++ b/lib/slop/types.rb @@ -51,9 +51,10 @@ module Slop # Cast the option argument to a Float. class FloatOption < Option + FLOAT_STRING_REGEXP = /\A[+-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?\z/.freeze + def call(value) - # TODO: scientific notation, etc. - value =~ /\A-?\d*\.*\d+\z/ && value.to_f + value =~ FLOAT_STRING_REGEXP && value.to_f end end |