Skip to content

Instantly share code, notes, and snippets.

@gmgent
Created March 8, 2011 18:50
Show Gist options
  • 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