lib/r-fxxk.rb in r-fxxk-0.3.0 vs lib/r-fxxk.rb in r-fxxk-0.4.0

- old
+ new

@@ -1,6 +1,6 @@ -class BrainFuck +class Brainfuck def initialize(options = {}) self.class.default_mapping.each do |key, default| operations[key] = options.has_key?(key) ? options[key] : default end end @@ -22,11 +22,11 @@ instance_variable_get(:@operations)[op] end end def compile(src) - BrainFuck.new.translate(self, src) + Brainfuck.new.translate(self, src) end def translate(other, src) other = other.new if other.kind_of?(Class) cur = 0 @@ -40,11 +40,11 @@ end dst end def hello_world - translate(BrainFuck, '>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-]<.>+++++++++++[<+++++>-]<.>++++++++[<+++>-]<.+++.------.--------.[-]>++++++++[<++++>-]<+.[-]++++++++++.') + translate(Brainfuck, '>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-]<.>+++++++++++[<+++++>-]<.>++++++++[<+++>-]<.+++.------.--------.[-]>++++++++[<++++>-]<+.[-]++++++++++.') end def fuck(src) src = compile(src) ptr = 0 @@ -95,12 +95,15 @@ end output.join end class << self - BrainFuck.default_mapping.keys.each do |op| + Brainfuck.default_mapping.keys.each do |op| define_method(op) do |val| default_mapping[op] = val end end end end + +# For backwards compatibility. +BrainFuck = Brainfuck