Skip to content

Instantly share code, notes, and snippets.

Jean-Christophe jcberthon

Block or report user

Report or block jcberthon

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
jcberthon / string_ext.rb
Created Jun 12, 2012 — forked from erskingardner/string_ext.rb
Convert String to Boolean value
View string_ext.rb
class String
def to_boolean
return true if self == true || self =~ (/(true|t|yes|y|1)$/i)
return false if self == false || self.nil? || self.empty? || self =~ (/(false|f|no|n|0)$/i)
raise"invalid value for Boolean: \"#{self}\"")
You can’t perform that action at this time.