Class: BitmapCompiler::Core::Editor
- Inherits:
-
Object
- Object
- BitmapCompiler::Core::Editor
- Defined in:
- lib/bitmap_compiler/core/editor.rb
Instance Attribute Summary collapse
-
#bitmap ⇒ Object
readonly
Returns the value of attribute bitmap.
Instance Method Summary collapse
-
#initialize(bitmap: nil) ⇒ Editor
constructor
A new instance of Editor.
- #process_line(input) ⇒ Object
- #run(file) ⇒ Object
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
#bitmap ⇒ Object (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
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 |