Skip to content

Instantly share code, notes, and snippets.

@gmgent
Created March 8, 2011 18:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gmgent/860759 to your computer and use it in GitHub Desktop.
Save gmgent/860759 to your computer and use it in GitHub Desktop.
def to_boolean(value, nil_value = false)
value.downcase! if value.class == String
case value
when "no","false",false, "0", 0
false
when "yes","true",true, "1", 1
true
when nil
nil_value
else
!!value
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment