instance method
numtok
Ruby on Rails 3.0.20
Since v2.3.18 Last seen in v3.0.20Available in: v2.3.18 v3.0.20
Signature
numtok(s)
No documentation comment.
Parameters
-
sreq
Source
# File activesupport/lib/active_support/json/backends/okjson.rb, line 230
def numtok(s)
m = /-?([1-9][0-9]+|[0-9])([.][0-9]+)?([eE][+-]?[0-9]+)?/.match(s)
if m && m.begin(0) == 0
if m[3] && !m[2]
[:val, m[0], Integer(m[1])*(10**Integer(m[3][1..-1]))]
elsif m[2]
[:val, m[0], Float(m[0])]
else
[:val, m[0], Integer(m[0])]
end
else
[]
end
end
Defined in activesupport/lib/active_support/json/backends/okjson.rb line 230
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::OkJson