Class: Bitmapped::Bitmap

Inherits:
Object
  • Object
show all
Defined in:
lib/bitmapped/bitmap.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#columnsObject

Returns the value of attribute columns.



9
10
11
# File 'lib/bitmapped/bitmap.rb', line 9

def columns
  @columns
end

#pixelsObject

Returns the value of attribute pixels.



9
10
11
# File 'lib/bitmapped/bitmap.rb', line 9

def pixels
  @pixels
end

#rowsObject

Returns the value of attribute rows.



9
10
11
# File 'lib/bitmapped/bitmap.rb', line 9

def rows
  @rows
end

#tableObject

Returns the value of attribute table.



9
10
11
# File 'lib/bitmapped/bitmap.rb', line 9

def table
  @table
end

Instance Method Details

#command(input) ⇒ Object



11
12
13
14
15
16
17
18
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
44
45
46
47
48
# File 'lib/bitmapped/bitmap.rb', line 11

def command(input)
  begin
    case input.shift
    when "I"
      Commands::InitialiserCommand.new.process_command(self, input)
    when "X", "exit"
      Commands::ExitCommand.new.process_command(self, input)
    when "C"
      Commands::ClearCommand.new.process_command(self, input)
    when "L"
      Commands::PixelFillCommand.new.process_command(self, input)
    when "V"
      Commands::VerticalLineCommand.new.process_command(self, input)
    when "H"
      Commands::HorizontalLineCommand.new.process_command(self, input)
    when "F"
      Commands::FillCommand.new.process_command(self, input)
    when "S"
      Commands::PrintTableCommand.new.process_command(self, input)
    when "T"
      Commands::PrintFancyTableCommand.new.process_command(self, input)
    when "R"
      Commands::RotateCommand.new.process_command(self, input)
    when "M"
      Commands::MirrorCommand.new.process_command(self, input)
    when "N"
      Commands::InvertCommand.new.process_command(self, input)
    else
      "Invalid Command"
    end
  rescue BitmapNotInitialised => bni
    "Bitmap has not been initialised, run command 'I' with valid arguments"
  rescue ParsingError => pe
    "Invalid parameters"
  rescue InvalidCoordinatesError => ice
    "Invalid co-ordinates"
  end
end