Sha256: 38b50bb143848f983be18771ec27997d13e22330adbaa8b0e9c77f1a74abe8e1

Contents?: true

Size: 1.18 KB

Versions: 4

Compression:

Stored size: 1.18 KB

Contents

require_relative 'logger'
require_relative 'runtime_error'

class Tailor

  # A Hashed data structure that simply defines the data needed to report a
  # problem
  class Problem < Hash
    include LogSwitch::Mixin

    # @param [Symbol] type The problem type.
    # @param [Fixnum] line The line of the file the problem was found on.
    # @param [Fixnum] column The column of the file line the problem was found on.
    # @param [String] message The message to tell the user about the problem.
    # @param [Fixnum] level The severity of the problem.
    def initialize(type, line, column, message, level)
      @type = type
      @line = line
      @column = column
      @message = message
      @level = level
      set_values
      subclass_name = self.class.to_s.sub(/^Tailor::/, '')
      msg = "<#{subclass_name}> #{self[:line]}[#{self[:column]}]: "
      msg << "#{@level.upcase}[:#{self[:type]}] #{self[:message]}"
      log msg
    end

    # Sets the standard values for the problem based on the type and binding.
    def set_values
      self[:type] = @type
      self[:line] = @line
      self[:column] = @column
      self[:message] = @message
      self[:level] = @level
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tailor-1.4.1 lib/tailor/problem.rb
tailor-1.4.0 lib/tailor/problem.rb
tailor-1.3.1 lib/tailor/problem.rb
tailor-1.3.0 lib/tailor/problem.rb