Class: Yarbf::BfInterpreter::BfProgramUnit

Inherits:
Object
  • Object
show all
Defined in:
lib/yarbf.rb

Overview

Program unit of Brainfuck.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(instruction, position) ⇒ BfProgramUnit

Returns a new instance of BfProgramUnit.



370
371
372
373
374
375
# File 'lib/yarbf.rb', line 370

def initialize(instruction, position)
  @instruction = instruction
  @position = position
  @match = nil
  @next = nil
end

Instance Attribute Details

#instructionObject (readonly)

Returns the value of attribute instruction.



367
368
369
# File 'lib/yarbf.rb', line 367

def instruction
  @instruction
end

#matchObject

Returns the value of attribute match.



368
369
370
# File 'lib/yarbf.rb', line 368

def match
  @match
end

#nextObject

Returns the value of attribute next.



368
369
370
# File 'lib/yarbf.rb', line 368

def next
  @next
end

#positionObject (readonly)

Returns the value of attribute position.



367
368
369
# File 'lib/yarbf.rb', line 367

def position
  @position
end

Instance Method Details

#inspectObject Also known as: to_s



377
378
379
380
381
382
# File 'lib/yarbf.rb', line 377

def inspect
  s = "{ ins: '#{@instruction}', pos: #{@position}"
  s += ", next: #{@next.position}" unless @next.nil?
  s += ", match: #{@match.position}" unless @match.nil?
  s + ' }'
end