Class: Slop::FloatOption
Overview
Cast the option argument to a Float.
Constant Summary collapse
- FLOAT_STRING_REGEXP =
/\A[+-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?\z/.freeze
Constants inherited from Option
Instance Attribute Summary
Attributes inherited from Option
#block, #config, #count, #desc, #flags, #value
Instance Method Summary collapse
Methods inherited from Option
#default_value, #ensure_call, #expects_argument?, #finish, #flag, #help?, #initialize, #key, #null?, #required?, #reset, #suppress_errors?, #tail, #tail?, #to_s, #underscore_flags?, #validate_type?
Constructor Details
This class inherits a constructor from Slop::Option
Instance Method Details
#call(value) ⇒ Object
87 88 89 |
# File 'lib/slop/types.rb', line 87 def call(value) value.to_f end |
#valid?(value) ⇒ Boolean
83 84 85 |
# File 'lib/slop/types.rb', line 83 def valid?(value) value =~ FLOAT_STRING_REGEXP end |