Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/mongocore/ext.rb
Instance Method Summary collapse
-
#to_bool ⇒ Object
Adding a to_bool method.
Instance Method Details
#to_bool ⇒ Object
Adding a to_bool method
13 14 15 16 17 18 |
# File 'lib/mongocore/ext.rb', line 13 def to_bool return true if self =~ (/^(true|yes|t|y|[1-9]+)$/i) return false if self.empty? || self =~ (/^(false|no|n|f|0)$/i) raise ArgumentError.new %{invalid value: #{self}} end |