Class: TTY::Coercer::Float

Inherits:
Object
  • Object
show all
Defined in:
lib/tty/coercer/float.rb

Overview

Coerce values into float number

Class Method Summary collapse

Class Method Details

.coerce(value, strict = true) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/tty/coercer/float.rb', line 9

def self.coerce(value, strict = true)
  Kernel.send(:Float, value.to_s)
rescue
  if strict
    raise InvalidArgument, "#{value} could not be coerced into Float"
  else
    value.to_f
  end
end