Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/zfaker/utils/module_utils.rb

Overview

String Class

Instance Method Summary collapse

Instance Method Details

#integer?Boolean



59
60
61
62
63
64
65
66
67
68
69
# File 'lib/zfaker/utils/module_utils.rb', line 59

def integer?
  [                          # In descending order of likeliness:
    /^[-+]?[1-9]([0-9]*)?$/, # decimal
    /^0[0-7]+$/,             # octal
    /^0x[0-9A-Fa-f]+$/,      # hexadecimal
    /^0b[01]+$/              # binary
  ].each do |match_pattern|
    return true if self =~ match_pattern
  end
  false
end