Class: ClosingComments::Source::Problem

Inherits:
Object
  • Object
show all
Defined in:
lib/closing_comments/source.rb

Instance Method Summary collapse

Constructor Details

#initialize(entity, line) ⇒ Problem

Returns a new instance of Problem.



67
68
69
70
# File 'lib/closing_comments/source.rb', line 67

def initialize(entity, line)
  @entity = entity
  @line = line
end

Instance Method Details

#columnObject



76
77
78
# File 'lib/closing_comments/source.rb', line 76

def column
  @line.index('end')
end

#fixObject



80
81
82
# File 'lib/closing_comments/source.rb', line 80

def fix
  @line[0...column] + @entity.ending
end

#lineObject



72
73
74
# File 'lib/closing_comments/source.rb', line 72

def line
  @entity.last_line
end

#messageObject



84
85
86
# File 'lib/closing_comments/source.rb', line 84

def message
  "missing #{@entity.entity} closing comment"
end

#to_hObject



88
89
90
91
92
93
94
# File 'lib/closing_comments/source.rb', line 88

def to_h
  {
    line: line,
    column: column,
    message: message,
  }
end