Class: AdaTruthy::LogicalGate
- Inherits:
-
Object
- Object
- AdaTruthy::LogicalGate
- Defined in:
- lib/ada_truthy/logical_gates/logical_gate.rb
Class Method Summary collapse
- .and(a, b, *others) ⇒ Object
- .nand(a, b, *others) ⇒ Object
- .nor(a, b, *others) ⇒ Object
- .not(a) ⇒ Object
- .or(a, b, *others) ⇒ Object
- .xnor(a, b, *others) ⇒ Object
- .xor(a, b, *others) ⇒ Object
Class Method Details
.and(a, b, *others) ⇒ Object
8 9 10 11 12 |
# File 'lib/ada_truthy/logical_gates/logical_gate.rb', line 8 def self.and(a, b, *others) return self.iand(a, b, others) if a.is_a? Integer return false if (others.include?(false) || !a || !b) return true end |
.nand(a, b, *others) ⇒ Object
14 15 16 |
# File 'lib/ada_truthy/logical_gates/logical_gate.rb', line 14 def self.nand(a, b, *others) self.not self.and(a, b, others) end |
.nor(a, b, *others) ⇒ Object
24 25 26 |
# File 'lib/ada_truthy/logical_gates/logical_gate.rb', line 24 def self.nor(a, b, *others) self.not self.or(a, b, others) end |
.not(a) ⇒ Object
3 4 5 6 |
# File 'lib/ada_truthy/logical_gates/logical_gate.rb', line 3 def self.not(a) return inot(a) if a.is_a? Integer return !a end |
.or(a, b, *others) ⇒ Object
18 19 20 21 22 |
# File 'lib/ada_truthy/logical_gates/logical_gate.rb', line 18 def self.or(a, b, *others) return self.ior(a, b, others) if a.is_a? Integer return true if others.include?(true) || a || b return false end |
.xnor(a, b, *others) ⇒ Object
38 39 40 |
# File 'lib/ada_truthy/logical_gates/logical_gate.rb', line 38 def self.xnor(a, b, *others) return !self.xor(a, b, others) end |
.xor(a, b, *others) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/ada_truthy/logical_gates/logical_gate.rb', line 28 def self.xor(a, b, *others) result = self.base_xor a, b others.each do |term| result = base_xor(result, term) end return result end |