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`)



483
484
485
# File 'lib/epitools/core_ext/numbers.rb', line 483

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)



476
477
478
# File 'lib/epitools/core_ext/numbers.rb', line 476

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