Class: BitmapCompiler::Core::BitmapController

Inherits:
Object
  • Object
show all
Includes:
BitmapActions
Defined in:
lib/bitmap_compiler/core/bitmap_controller.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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.



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

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

Instance Attribute Details

#bitmapObject (readonly)

Returns the value of attribute bitmap.



12
13
14
# File 'lib/bitmap_compiler/core/bitmap_controller.rb', line 12

def bitmap
  @bitmap
end

#inputObject (readonly)

Returns the value of attribute input.



12
13
14
# File 'lib/bitmap_compiler/core/bitmap_controller.rb', line 12

def input
  @input
end

Instance Method Details

#execute_command(input) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/bitmap_compiler/core/bitmap_controller.rb', line 14

def execute_command(input)
  @input = input.split

  case input[0]
  when 'I'
    create_bitmap(bitmap_hash)
  when 'C'
    clear
  when 'V'
    change_vertical_line(change_vertical_line_hash)
  when 'H'
    change_horizontal_line(change_horizontal_line_hash)
  when 'S'
    print
  else
    unknown_command
  end
end