9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/bitmap_cmd_editor/validators/fill_region_validator.rb', line 9
def validate(args, bitmap_columns, bitmap_rows)
begin
raise FillRegionArgumentError.new(
ErrorMessage.new(:command_wrong_arguments, {:arguments => 3}).show_content) unless args.count == 4
begin
columns= Integer(args[1])
rows= Integer(args[2])
rescue => err
raise TypeError.new(ErrorMessage.new(:coordinates_are_not_integer).show_content)
end
ValidatorHelper.out_of_range('columns',BitmapCmdEditor::MIN_COLUMNS,bitmap_columns,columns)
ValidatorHelper.out_of_range('rows',BitmapCmdEditor::MIN_ROWS,bitmap_rows,rows)
raise TypeError.new(ErrorMessage.new(:the_colour_is_invalid).show_content) unless ('A'..'Z').include?args[3]
:valid
rescue => err
err.message
end
end
|