Module: Cubic::CoreExtensions::Parse

Defined in:
lib/cubic/core_extensions/string/parse.rb

Instance Method Summary collapse

Instance Method Details

#integer?Boolean

Returns:

  • (Boolean)


4
5
6
7
8
9
10
11
12
13
14
# File 'lib/cubic/core_extensions/string/parse.rb', line 4

def integer?
  [
    /^[-+]?[1-9]([0-9]*)?$/,
    /^0[0-7]+$/,
    /^0x[0-9A-Fa-f]+$/,
    /^0b[01]+$/
  ].each do |match_pattern|
    return true if self =~ match_pattern
  end
  false
end