Sha256: 5970a9207f054d769db90d187463cb74836844f61aba7cbd8a17cbd9a9923f62

Contents?: true

Size: 833 Bytes

Versions: 2

Compression:

Stored size: 833 Bytes

Contents

require 'simplabs/excellent/core/error'

module Simplabs

  module Excellent

    module Checks

      class Base

        def initialize
          @errors = []
        end
  
        def position(offset = 0)
          "#{@line[2]}:#{@line[1] + offset}"
        end
  
        def evaluate_node(node)
          @file = node.file
          @line = node.line
          eval_method = "evaluate_#{node.node_type}"
          self.send(eval_method, node) if self.respond_to? eval_method
          evaluate(node) if self.respond_to? :evaluate
        end
  
        def add_error(message, info = {}, offset = 0)
          klass = self.class
          @errors << Simplabs::Excellent::Core::Error.new(klass, message, @file, @line + offset, info)
        end
  
        def errors
          @errors
        end

      end

    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
simplabs-excellent-1.0.0 lib/simplabs/excellent/checks/base.rb
simplabs-excellent-1.0.1 lib/simplabs/excellent/checks/base.rb