Sha256: 13ecbc145602af8b447f266a0ba5574861db5f7e72bf13f340771c59089ecc0e

Contents?: true

Size: 716 Bytes

Versions: 4

Compression:

Stored size: 716 Bytes

Contents

module Dydx
  module Helper
    def is_0?
      self == 0 || (is_a?(Num) && n == 0)
    end

    def is_1?
      self == 1 || (is_a?(Num) && n == 1)
    end

    def is_minus1?
      self == -1 || (is_a?(Num) && n == -1)
    end

    def is_multiple_of(x)
      is_multiple = if is_0?
        _(0)
      elsif self == x
        _(1)
      elsif is_a?(Formula) &&
        (f == x || g == x)
        f == x ? g : f
      else
        false
      end
    end

    {
      addition:       :+,
      subtraction:    :-,
      multiplication: :*,
      division:       :/,
      exponentiation: :^
    }.each do |operator_name, operator|
      define_method("#{operator_name}?") { @operator == operator }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dydx-0.0.4 lib/dydx/helper.rb
dydx-0.0.3 lib/dydx/helper.rb
dydx-0.0.2 lib/dydx/helper.rb
dydx-0.0.1 lib/dydx/helper.rb