Skip to content

Instantly share code, notes, and snippets.

@sebthemonster
Forked from gmgent/to_bool2.rb
Created September 18, 2012 10:39
Show Gist options
  • Save sebthemonster/3742521 to your computer and use it in GitHub Desktop.
Save sebthemonster/3742521 to your computer and use it in GitHub Desktop.
class Object
def to_boolean
compare_value = self.class == String ? self.downcase : self
case compare_value
when "no","false",false, "0", 0
false
when "yes","true",true, "1", 1
true
else
!!compare_value
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment