Class: Rational

Inherits:
Object show all
Defined in:
lib/epitools/core_ext/numbers.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.[](*args) ⇒ Object

Alternate initializer (Rational[1,2])



494
495
496
# File 'lib/epitools/core_ext/numbers.rb', line 494

def self.[](*args)
  Rational(*args)
end

Instance Method Details

#percent(decimals = 1) ⇒ Object

Convert the float to a rounded percentage string (eg: "42.5%") (see: Float#percent)



487
488
489
# File 'lib/epitools/core_ext/numbers.rb', line 487

def percent(decimals=1)
  to_f.percent(decimals)
end