Class: Roodi::Checks::Check

Inherits:
Object
  • Object
show all
Defined in:
lib/roodi/checks/check.rb

Instance Method Summary collapse

Constructor Details

#initializeCheck

Returns a new instance of Check.



9
10
11
# File 'lib/roodi/checks/check.rb', line 9

def initialize
  @errors = []
end

Instance Method Details

#add_error(info = {}, offset = 0) ⇒ Object



24
25
26
27
# File 'lib/roodi/checks/check.rb', line 24

def add_error(info = {}, offset = 0)
  klass = self.class
  @errors << Roodi::Core::Error.new(klass, info, "#{@line[2]}", "#{@line[1] + offset}")
end

#errorsObject



29
30
31
# File 'lib/roodi/checks/check.rb', line 29

def errors
  @errors
end

#evaluate_node_at_line(node, line) ⇒ Object



17
18
19
20
21
22
# File 'lib/roodi/checks/check.rb', line 17

def evaluate_node_at_line(node, line)
  @line = 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

#position(offset = 0) ⇒ Object



13
14
15
# File 'lib/roodi/checks/check.rb', line 13

def position(offset = 0)
  "#{@line[2]}:#{@line[1] + offset}"
end