diff options
author | Hansuk <flavono123@gmail.com> | 2020-01-17 10:45:22 +0900 |
---|---|---|
committer | Hansuk <flavono123@gmail.com> | 2020-01-17 10:45:22 +0900 |
commit | e28fbcf19c9e1b6d8875be680c6bb4f40ab0c21c (patch) | |
tree | 86cb923b01d602ca410fc6dc1734a3aaf29a3dc8 /lib | |
parent | 6995484ee3a4a505c1c8705709f8dc00899013b3 (diff) | |
download | slop-e28fbcf19c9e1b6d8875be680c6bb4f40ab0c21c.tar.gz |
admit comments
- https://github.com/leejarvis/slop/pull/250#discussion_r367361652
- https://github.com/leejarvis/slop/pull/250#discussion_r367420001
Signed-off-by: Hansuk <flavono123@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/slop/types.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/slop/types.rb b/lib/slop/types.rb index c1055ea..c53319c 100644 --- a/lib/slop/types.rb +++ b/lib/slop/types.rb @@ -51,8 +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) - value =~ /\A[+-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?\z/ && value.to_f + value =~ FLOAT_STRING_REGEXP && value.to_f end end |