Class: Epuber::Checker::TextChecker::MatchProblem

Inherits:
Epuber::Compiler::Problem show all
Defined in:
lib/epuber/checker/text_checker.rb

Instance Attribute Summary

Attributes inherited from Epuber::Compiler::Problem

#file_path, #level, #location, #message, #source

Instance Method Summary collapse

Methods inherited from Epuber::Compiler::Problem

caret_symbol, caret_symbols, formatted_match_line, remove_tabs, text_at, #to_s

Constructor Details

#initialize(match, message, file_path) ⇒ MatchProblem

Returns a new instance of MatchProblem.

Parameters:

  • message (String)
  • file_path (String)
  • match (MatchData)


17
18
19
20
21
22
23
24
25
26
# File 'lib/epuber/checker/text_checker.rb', line 17

def initialize(match, message, file_path)
  whole_text = match.pre_match + match.matched_string + match.post_match

  line = match.pre_match_lines.count
  column = (match.pre_match_lines.last || '').length + 1
  length = match.matched_string.length
  location = Epuber::Compiler::Problem::Location.new(line, column, length)

  super(:warn, message, whole_text, location: location, file_path: file_path)
end