Class: BitmapCompiler::Core::BitmapController
- Inherits:
-
Object
- Object
- BitmapCompiler::Core::BitmapController
- Includes:
- BitmapActions
- Defined in:
- lib/bitmap_compiler/core/bitmap_controller.rb
Overview
Responsibility: execute commands
Instance Attribute Summary collapse
-
#bitmap ⇒ Object
readonly
Returns the value of attribute bitmap.
-
#input ⇒ Object
readonly
Returns the value of attribute input.
Instance Method Summary collapse
- #execute_command(input) ⇒ Object
-
#initialize(bitmap = nil) ⇒ BitmapController
constructor
A new instance of BitmapController.
Methods included from BitmapActions
#change_color, #change_horizontal_line, #change_vertical_line, #clear, #create_bitmap, #print, #unknown_command
Constructor Details
#initialize(bitmap = nil) ⇒ BitmapController
Returns a new instance of BitmapController.
9 10 11 |
# File 'lib/bitmap_compiler/core/bitmap_controller.rb', line 9 def initialize(bitmap = nil) @bitmap = bitmap end |
Instance Attribute Details
#bitmap ⇒ Object (readonly)
Returns the value of attribute bitmap.
13 14 15 |
# File 'lib/bitmap_compiler/core/bitmap_controller.rb', line 13 def bitmap @bitmap end |
#input ⇒ Object (readonly)
Returns the value of attribute input.
13 14 15 |
# File 'lib/bitmap_compiler/core/bitmap_controller.rb', line 13 def input @input end |
Instance Method Details
#execute_command(input) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# 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 |