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)


5
6
7
8
9
10
11
# File 'lib/string_ext.rb', line 5

def is_number?
  begin
    true if Float(self)
  rescue # rubocop:disable Style/RescueStandardError
    false
  end
end

#trimObject



13
14
15
16
17
18
19
20
21
# File 'lib/string_ext.rb', line 13

def trim
  trimmed = strip

  if trimmed.nil?
    self
  else
    trimmed
  end
end