Class: ShellOpts::Grammar::FloatArgument
- Inherits:
-
ArgumentType
- Object
- ArgumentType
- ShellOpts::Grammar::FloatArgument
- Defined in:
- lib/shellopts/argument_type.rb
Instance Attribute Summary
Attributes inherited from ArgumentType
Instance Method Summary collapse
Methods inherited from ArgumentType
Instance Method Details
#convert(value) ⇒ Object
57 |
# File 'lib/shellopts/argument_type.rb', line 57 def convert(value) value.to_f end |
#match?(name, literal) ⇒ Boolean
50 51 52 53 54 |
# File 'lib/shellopts/argument_type.rb', line 50 def match?(name, literal) # https://stackoverflow.com/a/21891705/2130986 literal =~ /^[+-]?(?:0|[1-9]\d*)(?:\.(?:\d*[1-9]|0))?$/ or "Illegal decimal value in #{name}: #{literal}" end |
#value?(value) ⇒ Boolean
56 |
# File 'lib/shellopts/argument_type.rb', line 56 def value?(value) value.is_a?(Numeric) end |