Sha256: 3ecdcab660a6724724f1e730ca861f513fc0ad831a7f631ce1bfb8ed94d7f0c5

Contents?: true

Size: 746 Bytes

Versions: 3

Compression:

Stored size: 746 Bytes

Contents

module Polly::Math

class << self

  def min(*args)
    args.min
  end

  def max(*args)
    args.max
  end

  def ceil(val, ceil)
    (val.to_f / ceil.to_i).to_i * ceil.to_i 
  end

  def pv(i, length, pmt)
     pmt.to_f / i * (1 - (1 + i) ** -length.to_f)
  end

  # Some binary operators are not methods but part of Ruby's syntax. Since
  # there is no way to latch on to them, they'll have to be redefined.
  
  def br(test, exp1, exp2)
    test ? exp1 : exp2
  end

  def and(val1, val2)
    val1 && val2
  end

  def or(val1, val2)
    val1 || val2
  end

  def not(val)
    !val
  end
  alias_method :!, :not

  def not_eq(val1, val2)
    !(val1 == val2)
  end
  alias_method :!=, :not_eq

  # NOOP
  def self(obj)
    obj
  end

end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
polly-0.0.6 lib/polly/math.rb
polly-0.0.5 lib/polly/math.rb
polly-0.0.4 lib/polly/math.rb