Module: JamfRubyExtensions::String::Predicates

Included in:
String
Defined in:
lib/jamf/ruby_extensions/string/predicates.rb

Constant Summary collapse

INTEGER_RE =
/\A-?[0-9]+\Z/.freeze
FLOAT_RE =
/\A-?[0-9]+\.[0-9]+\Z/.freeze

Instance Method Summary collapse

Instance Method Details

#j_float?Boolean

Is this string also a floar? (i.e. it consists only of numberic digits)

Returns:

  • (Boolean)


49
50
51
# File 'lib/jamf/ruby_extensions/string/predicates.rb', line 49

def j_float?
  self =~ FLOAT_RE ? true : false
end

#j_integer?Boolean

Is this string also an integer? (i.e. it consists only of numberic digits, maybe with a dash in front)

Returns:

  • (Boolean)


40
41
42
# File 'lib/jamf/ruby_extensions/string/predicates.rb', line 40

def j_integer?
  self =~ INTEGER_RE ? true : false
end