Sha256: 9bcddd0dfa4d098e6b6ddb62d0b866c05b7fae8a8b1d444b9ffb058a4566137f

Contents?: true

Size: 992 Bytes

Versions: 10

Compression:

Stored size: 992 Bytes

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 [Binding] binding The context that the problem was discovered in.
    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

10 entries across 10 versions & 1 rubygems

Version Path
tailor-1.2.1 lib/tailor/problem.rb
tailor-1.2.0 lib/tailor/problem.rb
tailor-1.1.5 lib/tailor/problem.rb
tailor-1.1.4 lib/tailor/problem.rb
tailor-1.1.3 lib/tailor/problem.rb
tailor-1.1.2 lib/tailor/problem.rb
tailor-1.1.1 lib/tailor/problem.rb
tailor-1.1.0 lib/tailor/problem.rb
tailor-1.0.1 lib/tailor/problem.rb
tailor-1.0.0 lib/tailor/problem.rb