Sha256: f0de0943aeddd0bc0a841c3fa9fb4be5184709824f43574ea3f652465826d59f

Contents?: true

Size: 846 Bytes

Versions: 1

Compression:

Stored size: 846 Bytes

Contents

module MagicLogic
  module Operator
    def _ ope, l, r
      ope == :+ ? l : r
    end

    [:+, :*].each do |ope|
      define_method(ope) do |q|
        case q
        when Taut  then _ ope, $tout, self
        when UTaut then _ ope, self, $utout
        when self  then self
        else
          if neg?(q)
            (_ ope, $tout, $utout)
          elsif is_form?(ope.to_sym) && include?(q)
            self
          elsif q.is_form?(ope) && q.include?(self)
            q
          else
            FORM.new([self, q], ope)
          end
        end
      end
    end

    def ~@
      if    is_neg?  then p
      elsif is_form? then vars.map(&:~).inject(_ ope, :*, :+)
      else                NEG.new(self)
      end
    end

    def >=(q)
      (~self + q)
    end

    def <=>(q)
      (self >= q) * (q >= self)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
magic_logic-0.0.3 lib/magic_logic/operator.rb