Class: JsonRpcObjects::Utils::String

Inherits:
Object
  • Object
show all
Defined in:
lib/json-rpc-objects/utils/string.rb

Overview

String utility functions.

Since:

  • 0.4.4

Constant Summary collapse

NUMERIC =

Holds numeric matcher.

Since:

  • 0.4.4

/^\s*-?\d+(?:\.\d+)?\s*$/

Class Method Summary collapse

Class Method Details

.numeric?(string) ⇒ Boolean

Indicates, string is numeric, so consists of numbers only.

Parameters:

  • string (Source)

    source string

Returns:

  • (Boolean)

    true if yes, false in otherwise

Since:

  • 0.4.4



36
37
38
39
40
41
42
# File 'lib/json-rpc-objects/utils/string.rb', line 36

def self.numeric?(string)
    if string.match(NUMERIC)
        true
    else
        false
    end
end