Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/toolbox/boolean.rb,
lib/toolbox/integer.rb
Instance Method Summary collapse
-
#is_i? ⇒ Boolean
Adds the ability to check if String is an integer (both positive and negative values accepted).
-
#to_bool ⇒ Object
Extending String function to be able to convert a String 'true' or 'false' to a boolean true/false.
Instance Method Details
#is_i? ⇒ Boolean
Adds the ability to check if String is an integer (both positive and negative values accepted)
6 7 8 |
# File 'lib/toolbox/integer.rb', line 6 def is_i? !self.match(/^[-+]?[0-9]+$/).nil? end |
#to_bool ⇒ Object
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 |