Class: MagicLogic::FORM

Inherits:
Struct
  • Object
show all
Includes:
Base
Defined in:
lib/magic_logic.rb

Constant Summary

Constants included from Utils

Utils::ATOM_PREFIX

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

#dpll, #evl, #is_and?, #is_form?, #is_neg?, #is_or?, #neg?

Methods included from Operator

#<=>, #>=, #_, #~@

Constructor Details

#initialize(vars, ope) ⇒ FORM

Returns a new instance of FORM.



47
48
49
50
# File 'lib/magic_logic.rb', line 47

def initialize(vars, ope)
  self.vars = vars.map { |var| var.is_form?(ope) ? var.vars : var }.flatten
  self.ope = ope
end

Instance Attribute Details

#opeObject

Returns the value of attribute ope

Returns:

  • (Object)

    the current value of ope



45
46
47
# File 'lib/magic_logic.rb', line 45

def ope
  @ope
end

#varsObject

Returns the value of attribute vars

Returns:

  • (Object)

    the current value of vars



45
46
47
# File 'lib/magic_logic.rb', line 45

def vars
  @vars
end

Instance Method Details

#include?(p) ⇒ Boolean

Returns:

  • (Boolean)


53
# File 'lib/magic_logic.rb', line 53

def include?(p); vars.include?(p)                              end

#to_sObject



52
# File 'lib/magic_logic.rb', line 52

def to_s;        "(#{vars.map(&:to_s).join(_ ope, '|', '&')})" end