Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/toolbox/boolean.rb,
lib/toolbox/integer.rb

Instance Method Summary collapse

Instance Method Details

#is_i?Boolean

Adds the ability to check if String is an integer (both positive and negative values accepted)

Returns:

  • (Boolean)


6
7
8
# File 'lib/toolbox/integer.rb', line 6

def is_i?
  !self.match(/^[-+]?[0-9]+$/).nil?
end

#to_boolObject

Extending String function to be able to convert a String 'true' or 'false' to a boolean true/false. See the Boolean module for usage



7
8
9
# File 'lib/toolbox/boolean.rb', line 7

def to_bool
  (self =~ /^true$/i) == 0
end