Class: Yarbf::BfInterpreter::BfProgramUnit
- Inherits:
-
Object
- Object
- Yarbf::BfInterpreter::BfProgramUnit
- Defined in:
- lib/yarbf.rb
Overview
Program unit of Brainfuck.
Instance Attribute Summary collapse
-
#instruction ⇒ Object
readonly
Returns the value of attribute instruction.
-
#match ⇒ Object
Returns the value of attribute match.
-
#next ⇒ Object
Returns the value of attribute next.
-
#position ⇒ Object
readonly
Returns the value of attribute position.
Instance Method Summary collapse
-
#initialize(instruction, position) ⇒ BfProgramUnit
constructor
A new instance of BfProgramUnit.
- #inspect ⇒ Object (also: #to_s)
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
#instruction ⇒ Object (readonly)
Returns the value of attribute instruction.
367 368 369 |
# File 'lib/yarbf.rb', line 367 def instruction @instruction end |
#match ⇒ Object
Returns the value of attribute match.
368 369 370 |
# File 'lib/yarbf.rb', line 368 def match @match end |
#next ⇒ Object
Returns the value of attribute next.
368 369 370 |
# File 'lib/yarbf.rb', line 368 def next @next end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
367 368 369 |
# File 'lib/yarbf.rb', line 367 def position @position end |
Instance Method Details
#inspect ⇒ Object 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 |