Class: PrintPrimesTable::Validators::ErrorMessage
- Inherits:
-
Object
- Object
- PrintPrimesTable::Validators::ErrorMessage
- Defined in:
- lib/print_primes_table/validators/error_message.rb
Overview
An intance contains te error_type and a message to the user
Constant Summary
- MESSAGES =
{ :command_wrong_arguments => "the program allowed %{max} argument maximun, you typed %{argument_num}", :command_wrong_type_arguments => "Sorry, %{argument} is not an integer", :less_than_min => "The minimun quantity is %{min}, so %{argument} is not valid" }
Instance Method Summary (collapse)
-
- (ErrorMessage) initialize(error_type = :invalid, args = {}, content = nil)
constructor
initialize the message.
-
- (Object) show_content
Text message [String] it could contain arguments.
Constructor Details
- (ErrorMessage) initialize(error_type = :invalid, args = {}, content = nil)
initialize the message
16 17 18 19 20 21 22 23 24 |
# File 'lib/print_primes_table/validators/error_message.rb', line 16 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
26 27 28 |
# File 'lib/print_primes_table/validators/error_message.rb', line 26 def show_content "\n" + @content % @args end |