Class: RELI::Abstract
- Inherits:
-
Object
- Object
- RELI::Abstract
- Defined in:
- lib/reli/abstract.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Abstract
constructor
A new instance of Abstract.
- #run(code) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Abstract
Returns a new instance of Abstract.
4 5 6 7 8 9 10 |
# File 'lib/reli/abstract.rb', line 4 def initialize( = {}) @memory = [] @buffer = [] @pointer = @memory[0] = 0 @size = 1 @break = 0 end |
Class Method Details
.change(new, old) ⇒ Object
29 30 31 32 |
# File 'lib/reli/abstract.rb', line 29 def self.change(new, old) old_method = instance_method("exec_#{old}") define_method("exec_#{new}", old_method) end |
.on(char, &block) ⇒ Object
25 26 27 |
# File 'lib/reli/abstract.rb', line 25 def self.on(char, &block) define_method "exec_#{char}", &block end |
Instance Method Details
#run(code) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/reli/abstract.rb', line 12 def run(code) @code = code.split(//u) @index = 0 code_length = @code.length while @index < code_length do method_name = "exec_#{@code[@index, @size].join}" @index += @break next unless respond_to?(method_name) send(method_name) end @buffer.join end |