Module: YABFI::Encoder

Defined in:
lib/yabfi/encoder.rb

Overview

This module encodes the human-readable instruction names to integers.

Constant Summary collapse

INSTRUCTIONS =

Mapping of human readable instruction names to their encoded integers.

{
  change_value: 0,
  change_pointer: 1,
  get: 2,
  put: 3,
  branch_if_zero: 4,
  branch_not_zero: 5
}

Class Method Summary collapse

Class Method Details

.encode(ary) ⇒ Object

Encode a list of instructions into



17
18
19
# File 'lib/yabfi/encoder.rb', line 17

def encode(ary)
  ary.map { |(code, argument)| [INSTRUCTIONS[code], argument] }
end