Class: LogicTools::VoidCube

Inherits:
Cube
  • Object
show all
Defined in:
lib/logic_tools/logicsimplify_es.rb

Overview

Represents an empty cube.

NOTE: for irredundant usage only.

Instance Method Summary collapse

Methods inherited from Cube

#blocking_matrix, #can_merge?, #consensus, #distance, #each_minterm, #include?, #intersect, #intersects?, #merge, #sharp, #width

Constructor Details

#initialize(size) ⇒ VoidCube



142
143
144
145
146
147
# 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

Instance Method Details

#<=>(cube) ⇒ Object

:nodoc:



198
199
200
# File 'lib/logic_tools/logicsimplify_es.rb', line 198

def <=>(cube) #:nodoc:
    @vbits <=> cube.bits
end

#==(cube) ⇒ Object Also known as: eql?

Compares with another cube.



194
195
196
# File 'lib/logic_tools/logicsimplify_es.rb', line 194

def ==(cube) # :nodoc:
    @vbits == cube.bits
end

#[](i) ⇒ Object

Gets the char value of bit i.



214
215
216
# File 'lib/logic_tools/logicsimplify_es.rb', line 214

def [](i)
    @vbits[i]
end

#[]=(i, b) ⇒ Object

Sets the char value of bit i to b.

Invalid for a VoidCube.


226
227
228
# File 'lib/logic_tools/logicsimplify_es.rb', line 226

def []=(i,b)
    raise "A VoidCube cannot be modified."
end

#cloneObject Also known as: dup

duplicates the cube.



208
209
210
# File 'lib/logic_tools/logicsimplify_es.rb', line 208

def clone # :nodoc:
    VoidCube.new(self.width)
end

#each_byte(&blk) ⇒ Object

Iterates over the bits of the cube as bytes.

Returns an enumerator if no block given.


165
166
167
168
169
170
171
# 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) ⇒ Object Also known as: each

Iterates over the bits of the cube as chars.

Returns an enumerator if no block given.


176
177
178
179
180
181
182
# 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

#eval(input) ⇒ Object

Evaluates the corresponding function’s value for a binary input.

+input+ is assumed to be an integer.
Returns the evaluation result as a boolean.


153
154
155
# File 'lib/logic_tools/logicsimplify_es.rb', line 153

def eval(input)
    return false
end

#getbyte(i) ⇒ Object

Gets the byte value of bit i.



219
220
221
# File 'lib/logic_tools/logicsimplify_es.rb', line 219

def getbyte(i)
    @vbits.getbyte(i)
end

#hashObject

Gets the hash of a cube



203
204
205
# File 'lib/logic_tools/logicsimplify_es.rb', line 203

def hash
    @vbits.hash
end

#setbyte(i, b) ⇒ Object

Sets the byte value of bit i to b.

Invalid for a VoidCube.


233
234
235
# File 'lib/logic_tools/logicsimplify_es.rb', line 233

def setbyte(i,b)
    raise "A VoidCube cannot be modified."
end

#to_sObject

Converts to a string.



158
159
160
# File 'lib/logic_tools/logicsimplify_es.rb', line 158

def to_s # :nodoc:
    return @vbits.clone
end