Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/backups/ext/string.rb,
lib/backups/ext/string.rb
Instance Method Summary collapse
Instance Method Details
#squish! ⇒ Object
13 14 15 16 17 18 |
# File 'lib/backups/ext/string.rb', line 13 def squish! gsub!(/\A[[:space:]]+/, '') gsub!(/[[:space:]]+\z/, '') gsub!(/[[:space:]]+/, ' ') self end |
#to_bool ⇒ Object
3 4 5 6 7 |
# File 'lib/backups/ext/string.rb', line 3 def to_bool return true if self == true || self =~ (/^(true|t|yes|y|1)$/i) return false if self == false || self.blank? || self =~ (/^(false|f|no|n|0)$/i) raise ArgumentError.new("invalid value for Boolean: \"#{self}\"") end |