Class: Error
- Inherits:
-
Object
- Object
- Error
- Defined in:
- lib/classes/error.rb
Instance Attribute Summary collapse
-
#err_type ⇒ Object
Returns the value of attribute err_type.
-
#file_path ⇒ Object
Returns the value of attribute file_path.
-
#line ⇒ Object
Returns the value of attribute line.
-
#variable ⇒ Object
Returns the value of attribute variable.
Instance Method Summary collapse
-
#initialize(line, err_type, fpath, *variable) ⇒ Error
constructor
rubocop:disable Lint/UnusedMethodArgument.
-
#print_err(line, type, path, *variable) ⇒ Object
rubocop:enable Lint/UnusedMethodArgument.
Constructor Details
#initialize(line, err_type, fpath, *variable) ⇒ Error
rubocop:disable Lint/UnusedMethodArgument
5 6 7 8 9 |
# File 'lib/classes/error.rb', line 5 def initialize(line, err_type, fpath, *variable) @line = line @err_type = err_type @file_path = fpath end |
Instance Attribute Details
#err_type ⇒ Object
Returns the value of attribute err_type.
2 3 4 |
# File 'lib/classes/error.rb', line 2 def err_type @err_type end |
#file_path ⇒ Object
Returns the value of attribute file_path.
2 3 4 |
# File 'lib/classes/error.rb', line 2 def file_path @file_path end |
#line ⇒ Object
Returns the value of attribute line.
2 3 4 |
# File 'lib/classes/error.rb', line 2 def line @line end |
#variable ⇒ Object
Returns the value of attribute variable.
2 3 4 |
# File 'lib/classes/error.rb', line 2 def variable @variable end |
Instance Method Details
#print_err(line, type, path, *variable) ⇒ Object
rubocop:enable Lint/UnusedMethodArgument
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/classes/error.rb', line 12 def print_err(line, type, path, *variable) error_hash = { 'VAR_NAMING_ERR': 'VariableName Error: Uppercase|Numbers used to Start a Variable name.', 'CLASS_NAME_ERR': 'ClassName Error: Ensure classes Begin With Uppercase and is not Snake-Cased.', 'SPACING_ERR': 'Spacing Error: Redundant Space(s).', 'CLASS_COUNT_ERR': 'Count Error: Multiple Classes Defined in a Module.', 'UNUSED_VAR_ERR': "Warning: Unused Variable ** #{variable[0]} ** Detected." } emit_err = lambda { |key| if type == 'UNUSED_VAR_ERR' && key[0].to_s == type puts "#{key[1].to_s.yellow} On Line #{line.to_s.yellow} in #{path.to_s.yellow}" if line puts elsif type != 'UNUSED_VAR_ERR' && key[0].to_s == type puts "#{key[1].to_s.red} Detected On Line #{line.to_s.yellow} in #{path.to_s.yellow}" puts end } error_hash.each(&emit_err) end |