class Stellar::Price
reopen class
Constants
- MAX_PRECISION
Public Class Methods
from_f(number)
click to toggle source
# File lib/stellar/price.rb, line 8 def self.from_f(number) best_r = Util::ContinuedFraction.best_r(number, MAX_PRECISION) new({ n: best_r.numerator, d: best_r.denominator }) end
Public Instance Methods
inspect()
click to toggle source
# File lib/stellar/price.rb, line 28 def inspect "#<Stellar::Price #{self}>" end
invert()
click to toggle source
# File lib/stellar/price.rb, line 16 def invert self.class.new(n:d,d:n) end
to_f()
click to toggle source
# File lib/stellar/price.rb, line 20 def to_f n / d.to_f end
to_s()
click to toggle source
# File lib/stellar/price.rb, line 24 def to_s "#{n} / #{d}" end