Sha256: 03b09853e3d979447ac2eb0c286fe6a8cce43a72cb2118c6369ee0b732258f24

Contents?: true

Size: 968 Bytes

Versions: 3

Compression:

Stored size: 968 Bytes

Contents

# encoding: utf-8
# (c) 2011-2015 Martin Poljak (martin@poljak.cz)

##
# Main JSON-RPC Objects module.
#

module JsonRpcObjects

    ##
    # Module for utility functions. Large part ported from 'hash-utils'.
    # @since 0.4.4
    #
    
    module Utils
    
        ##
        # String utility functions.
        #
        
        class String
          
            ##
            # Holds numeric matcher.
            #
          
            NUMERIC = /^\s*-?\d+(?:\.\d+)?\s*$/
              
            ##
            # Indicates, string is numeric, so consists of numbers only.
            #
            # @param [Source] string  source string
            # @return [Boolean] +true+ if yes, +false+ in otherwise
            #
            
            def self.numeric?(string)
                if string.match(NUMERIC)
                    true
                else
                    false
                end
            end
        end
        
    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
json-rpc-objects-0.4.6 lib/json-rpc-objects/utils/string.rb
json-rpc-objects-0.4.5 lib/json-rpc-objects/utils/string.rb
json-rpc-objects-0.4.4 lib/json-rpc-objects/utils/string.rb