Method not available on this version
This method is only available on newer versions. The first available version of the method is shown here.
parse_numeric(name)
private
Check if the peek is numeric format and
return a Float or Integer. Check if the peek is included in enum if
enum is provided. Otherwise raises an error.
Show source
def parse_numeric(name)
return shift if peek.is_a?(Numeric)
unless peek =~ NUMERIC && $& == peek
raise MalformattedArgumentError, "Expected numeric value for '#{name}'; got #{peek.inspect}"
end
value = $&.index(".") ? shift.to_f : shift.to_i
if @switches.is_a?(Hash) && switch = @switches[name]
if switch.enum && !switch.enum.include?(value)
raise MalformattedArgumentError, "Expected '#{name}' to be one of #{switch.enum.join(', ')}; got #{value}"
end
end
value
end