class String
Public Instance Methods
deep_strip()
click to toggle source
# File lib/acts_as_moonable/core_ext.rb, line 23 def deep_strip self.gsub(/([[:blank:]])+/, ' ').strip end
deep_strip!()
click to toggle source
# File lib/acts_as_moonable/core_ext.rb, line 14 def deep_strip! pattern = /([[:blank:]])+/ if self.match? pattern self.gsub!(pattern, ' ').strip! else self.strip! end end
is_numeric?()
click to toggle source
# File lib/acts_as_moonable/core_ext.rb, line 7 def is_numeric? # `!!` converts parsed number to `true` !!Kernel.Float(self) rescue TypeError, ArgumentError false end
numeric?()
click to toggle source
# File lib/acts_as_moonable/core_ext.rb, line 2 def numeric? return true if self =~ /\A\d+\Z/ true if Float(self) rescue false end