Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/acts_as_moonable/core_ext.rb
Instance Method Summary collapse
Instance Method Details
#deep_strip ⇒ Object
23 24 25 |
# File 'lib/acts_as_moonable/core_ext.rb', line 23 def deep_strip self.gsub(/([[:blank:]])+/, ' ').strip end |
#deep_strip! ⇒ Object
14 15 16 17 18 19 20 21 |
# 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? ⇒ Boolean
7 8 9 10 11 12 |
# 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? ⇒ Boolean
2 3 4 5 |
# 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 |