Class: BitmapCompiler::Core::Editor

Inherits:
Object
  • Object
show all
Defined in:
lib/bitmap_compiler/core/editor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bitmap: nil) ⇒ Editor

Returns a new instance of Editor.



8
9
10
# File 'lib/bitmap_compiler/core/editor.rb', line 8

def initialize(bitmap: nil)
  @bitmap = bitmap
end

Instance Attribute Details

#bitmapObject (readonly)

Returns the value of attribute bitmap.



6
7
8
# File 'lib/bitmap_compiler/core/editor.rb', line 6

def bitmap
  @bitmap
end

Instance Method Details

#process_line(input) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/bitmap_compiler/core/editor.rb', line 18

def process_line(input)
  output = execute(input)

  @bitmap = output.bitmap if output.bitmap

  output.print
end

#run(file) ⇒ Object

Raises:



12
13
14
15
16
# File 'lib/bitmap_compiler/core/editor.rb', line 12

def run(file)
  raise IncorrectFileError if file.nil? || !File.exist?(file)

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