Class: BitmapCmdEditor::Validators::ErrorMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/bitmap_cmd_editor/validators/error_message.rb

Overview

An intance contains te error_type and a message to the user

Author:

Constant Summary

MESSAGES =
{
	:invalid => "This operation is invalid",
	:command_not_exist => "This command is not available, please check the available commands",
	:more_than_max => "the maximun %{obj} allowed are %{max} and you want %{quantity}",
	:less_than_min => "the minimun %{obj} allowed is %{min} and you want %{quantity}",
	:command_wrong_arguments => "this command require %{arguments} arguments",
	:clear_image_wrongs_arguments => "clear image hasn't arguments",
	:print_table_arguments => "print table hasn't arguments",
	:colours_pixel_out_of_range => "a valid %{obj} values are between %{min} and %{max}, and you try %{quantity}",
	:coordinates_are_not_integer => "the coordinates M N must be integers",
	:out_of_range => "a valid %{obj} values are between %{min} and %{max}, and you try %{quantity}",
	:the_colour_is_invalid => "the colour must be a Capital Letter A-Z"
}

Instance Method Summary (collapse)

Constructor Details

- (ErrorMessage) initialize(error_type = :invalid, args = {}, content = nil)

initialize the message

Parameters:

  • content (String) (defaults to: nil)

    text message to the user

  • error_type (Symbol) (defaults to: :invalid)

    to qualifies the error

  • args (Hash) (defaults to: {})

    to include params in the response



23
24
25
26
27
28
29
30
31
# File 'lib/bitmap_cmd_editor/validators/error_message.rb', line 23

def initialize(error_type = :invalid,  args = {}, content = nil)
	unless content
		@content=MESSAGES[error_type]
	else
		@content = content
	end
	@error_type = error_type
	@args = args
end

Instance Method Details

- (Object) show_content

Returns text message [String] it could contain arguments

Returns:

  • text message [String] it could contain arguments



33
34
35
# File 'lib/bitmap_cmd_editor/validators/error_message.rb', line 33

def show_content
	"\n" + @content % @args
end