Class: String

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

Overview

Convert string to float or integer if applicable.

Instance Method Summary collapse

Instance Method Details

#to_numObject


39
40
41
42
43
44
45
46
47
48
49
# File 'lib/BioDSL.rb', line 39

def to_num
  Integer(self)
  to_i
rescue ArgumentError
  begin
    Float(self)
    to_f
  rescue ArgumentError
    self
  end
end