class BitmapCompiler::Core::BitmapController
Responsibility: execute commands
Attributes
bitmap[R]
input[R]
Public Class Methods
new(bitmap = nil)
click to toggle source
# File lib/bitmap_compiler/core/bitmap_controller.rb, line 9 def initialize(bitmap = nil) @bitmap = bitmap end
Public Instance Methods
execute_command(input)
click to toggle source
# File lib/bitmap_compiler/core/bitmap_controller.rb, line 15 def execute_command(input) @input = input.split case input[0] when 'I' create_bitmap(bitmap_hash) when 'C' clear when 'L' change_color(pixel_hash) when 'V' change_vertical_line(vertical_line_hash) when 'H' change_horizontal_line(horizontal_line_hash) when 'S' print else unknown_command end end
Private Instance Methods
bitmap_hash()
click to toggle source
# File lib/bitmap_compiler/core/bitmap_controller.rb, line 38 def bitmap_hash { width: Integer(input[1]), height: Integer(input[2]) } end
horizontal_line_hash()
click to toggle source
# File lib/bitmap_compiler/core/bitmap_controller.rb, line 45 def horizontal_line_hash { start_row: Integer(input[1]), end_row: Integer(input[2]), column: Integer(input[3]), color: input[4] } end
pixel_hash()
click to toggle source
# File lib/bitmap_compiler/core/bitmap_controller.rb, line 54 def pixel_hash { row: Integer(input[1]), column: Integer(input[2]), color: input[3] } end
vertical_line_hash()
click to toggle source
# File lib/bitmap_compiler/core/bitmap_controller.rb, line 62 def vertical_line_hash { row: Integer(input[1]), start_column: Integer(input[2]), end_column: Integer(input[3]), color: input[4] } end