Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/string_ext.rb

Instance Method Summary collapse

Instance Method Details

#is_number?Boolean

see if string is numeric

Returns:

  • (Boolean)


3
4
5
# File 'lib/string_ext.rb', line 3

def is_number?
  true if Float(self) rescue false
end

#trimObject



7
8
9
10
11
12
13
14
15
# File 'lib/string_ext.rb', line 7

def trim
  trimmed = self.strip

  if trimmed == nil
    self
  else
    trimmed
  end
end