instance method numtok

Ruby on Rails 3.0.20

Since v2.3.18 Last seen in v3.0.20

Available in: v2.3.18 v3.0.20

Signature

numtok(s)

No documentation comment.

Parameters

s req
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

Type at least 2 characters to search.

↑↓ navigate · open · esc close