diff options
author | Rick Hull <rick.hull@gmail.com> | 2014-12-29 01:36:32 -0500 |
---|---|---|
committer | Rick Hull <rick.hull@gmail.com> | 2014-12-29 12:31:20 -0500 |
commit | 1ef4327cef9f74caaafc2dcb8201aa71f0eff17d (patch) | |
tree | 208fa3000a76e28b0fa51c2f701fe8f46c9149e9 /lib | |
parent | 6e0db709d5c77d9cca1559da8a118d358734275f (diff) | |
download | slop-1ef4327cef9f74caaafc2dcb8201aa71f0eff17d.tar.gz |
add Float support
- in lib/
- in test/
- in README
Diffstat (limited to 'lib')
-rw-r--r-- | lib/slop/types.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/slop/types.rb b/lib/slop/types.rb index c7db245..cc10e63 100644 --- a/lib/slop/types.rb +++ b/lib/slop/types.rb @@ -27,6 +27,13 @@ module Slop end IntOption = IntegerOption + class FloatOption < Option + def call(value) + # TODO: scientific notation, etc. + value =~ /\A\d*\.*\d+\z/ && value.to_f + end + end + class ArrayOption < Option def call(value) @value ||= [] |