Class: BitmapCmdEditor::Bitmap
- Inherits:
-
Object
- Object
- BitmapCmdEditor::Bitmap
- Defined in:
- lib/bitmap_cmd_editor/bitmap.rb
Overview
It’s the main object is instantiated empty when the application start
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
-
#table ⇒ Object
readonly
Returns the value of attribute table.
Instance Method Summary collapse
-
#initialize ⇒ Bitmap
constructor
A new instance of Bitmap.
-
#process_command(input) ⇒ Object
process the operations commands availables view the constant COMMANDS, X is excluded because it is a system command not a bitmap command.
Constructor Details
#initialize ⇒ Bitmap
Returns a new instance of Bitmap.
9 10 11 12 13 |
# File 'lib/bitmap_cmd_editor/bitmap.rb', line 9 def initialize @table=[] @columns = 0 @rows = 0 end |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
6 7 8 |
# File 'lib/bitmap_cmd_editor/bitmap.rb', line 6 def columns @columns end |
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
6 7 8 |
# File 'lib/bitmap_cmd_editor/bitmap.rb', line 6 def rows @rows end |
#table ⇒ Object (readonly)
Returns the value of attribute table.
6 7 8 |
# File 'lib/bitmap_cmd_editor/bitmap.rb', line 6 def table @table end |
Instance Method Details
#process_command(input) ⇒ Object
process the operations commands availables view the constant COMMANDS, X is excluded because it is a system command not a bitmap command
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/bitmap_cmd_editor/bitmap.rb', line 19 def process_command(input) validator=Validators::CommandValidator.validate(input) if validator == :valid args = input.split(' ') case args[0] when 'I' create_image(args) when 'C' clear_image(args) when 'L' colours_pixel(args) when 'V' draw_vertical_line(args) when 'H' draw_horizontal_line(args) when 'F' fill_region(args) when 'S' print_table(args) end else validator end end |