class LogicTools::VoidCube
Represents an empty cube.
NOTE: for irredundant usage only.
Public Class Methods
new(size)
click to toggle source
Calls superclass method
LogicTools::Cube::new
# File lib/logic_tools/logicsimplify_es.rb, line 142 def initialize(size) # NOTE: This bit string is a phony, since the cube is void. super("-" * size,false) # The real bits @vbits = " " * size end
Public Instance Methods
[](i)
click to toggle source
Gets the char value of bit i
.
# File lib/logic_tools/logicsimplify_es.rb, line 214 def [](i) @vbits[i] end
[]=(i,b)
click to toggle source
Sets the char value of bit i
to b
.
Invalid for a VoidCube
.
# File lib/logic_tools/logicsimplify_es.rb, line 226 def []=(i,b) raise "A VoidCube cannot be modified." end
each_byte(&blk)
click to toggle source
Iterates over the bits of the cube as bytes.
Returns an enumerator if no block given.
# File lib/logic_tools/logicsimplify_es.rb, line 165 def each_byte(&blk) # No block given? Return an enumerator. return to_enum(:each_byte) unless block_given? # Block given? Apply it on each bit. @vbits.each_byte(&blk) end
each_char(&blk)
click to toggle source
Iterates over the bits of the cube as chars.
Returns an enumerator if no block given.
# File lib/logic_tools/logicsimplify_es.rb, line 176 def each_char(&blk) # No block given? Return an enumerator. return to_enum(:each_char) unless block_given? # Block given? Apply it on each bit. @vbits.each_char(&blk) end
Also aliased as: each
eval(input)
click to toggle source
Evaluates the corresponding function's value for a binary input
.
input
is assumed to be an integer. Returns the evaluation result as a boolean.
# File lib/logic_tools/logicsimplify_es.rb, line 153 def eval(input) return false end
getbyte(i)
click to toggle source
Gets the byte value of bit i
.
# File lib/logic_tools/logicsimplify_es.rb, line 219 def getbyte(i) @vbits.getbyte(i) end
hash()
click to toggle source
Gets the hash of a cube
# File lib/logic_tools/logicsimplify_es.rb, line 203 def hash @vbits.hash end
setbyte(i,b)
click to toggle source
Sets the byte value of bit i
to b
.
Invalid for a VoidCube
.
# File lib/logic_tools/logicsimplify_es.rb, line 233 def setbyte(i,b) raise "A VoidCube cannot be modified." end
Protected Instance Methods
bits()
click to toggle source
The bit string defining the cube.
Should not be modified directly, hence set as protected.
# File lib/logic_tools/logicsimplify_es.rb, line 188 def bits raise "A VoidCube cannot be modified." end