class BitmapCompiler::Core::Editor

Responsibility: process the files

Attributes

bitmap[R]

Public Class Methods

new(bitmap: nil) click to toggle source
# File lib/bitmap_compiler/core/editor.rb, line 9
def initialize(bitmap: nil)
  @bitmap = bitmap
end

Public Instance Methods

process_line(input) click to toggle source
# File lib/bitmap_compiler/core/editor.rb, line 19
def process_line(input)
  output = execute(input)

  @bitmap = output.bitmap if output.bitmap

  output.print
end
run(file) click to toggle source
# File lib/bitmap_compiler/core/editor.rb, line 13
def run(file)
  raise BitmapCompiler::Core::Errors::IncorrectFileError if file.nil? || !File.exist?(file)

  File.open(file).each { |line| process_line(line.chomp) }
end

Private Instance Methods

execute(input) click to toggle source
# File lib/bitmap_compiler/core/editor.rb, line 29
def execute(input)
  bitmap_compiler = BitmapController.new(bitmap)
  bitmap_compiler.execute_command(input)
end