Sha256: 09b83a97bc3a227289a7a4ff4d8b06a1efb129bcd2392f24924a1c08a8e16f10

Contents?: true

Size: 1.17 KB

Versions: 8

Compression:

Stored size: 1.17 KB

Contents

class Error
  attr_accessor :line, :err_type, :file_path, :variable

  # rubocop:disable Lint/UnusedMethodArgument
  def initialize(line, err_type, fpath, *variable)
    @line = line
    @err_type = err_type
    @file_path = fpath
  end
  # rubocop:enable Lint/UnusedMethodArgument

  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
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
jscop-0.1.9 lib/classes/error.rb
jscop-0.1.8 lib/classes/error.rb
jscop-0.1.7 lib/classes/error.rb
jscop-0.1.6 lib/classes/error.rb
jscop-0.1.5 lib/classes/error.rb
jscop-0.1.4 lib/classes/error.rb
jscop-0.1.3 lib/classes/error.rb
jscop-0.1.2 lib/classes/error.rb