Skip to content

Instantly share code, notes, and snippets.

@timothee-alby
timothee-alby / to_bool.rb
Last active August 29, 2015 14:08 — forked from equivalent/README.md
Easily any type to boolean in Ruby
module StringToBoolean
def to_bool
return true if self == true || self.strip =~ (/\A(true|t|yes|y|1)\Z/i)
false
end
end
class String; include StringToBoolean; end
module BooleanToBoolean
def to_bool;return self; end