Class: RDocRuboCop::RDoc

Inherits:
Object
  • Object
show all
Defined in:
lib/rdoc_rubocop/rdoc.rb,
lib/rdoc_rubocop/rdoc/line.rb,
lib/rdoc_rubocop/rdoc/ruby_snippet.rb

Defined Under Namespace

Classes: Line, RubySnippet

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ RDoc

Returns a new instance of RDoc.



9
10
11
12
13
14
# File 'lib/rdoc_rubocop/rdoc.rb', line 9

def initialize(text)
  @text = text

  @ruby_snippets = []
  @parsed = false
end

Instance Attribute Details

#ruby_snippetsObject (readonly)

Returns the value of attribute ruby_snippets.



7
8
9
# File 'lib/rdoc_rubocop/rdoc.rb', line 7

def ruby_snippets
  @ruby_snippets
end

#textObject (readonly)

Returns the value of attribute text.



6
7
8
# File 'lib/rdoc_rubocop/rdoc.rb', line 6

def text
  @text
end

Instance Method Details

#applyObject



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rdoc_rubocop/rdoc.rb', line 21

def apply
  lines = text_lines

  @ruby_snippets.reverse_each do |ruby_snippet|
    next unless ruby_snippet.corrected_text_with_indent

    index = ruby_snippet.lineno[0] - 1
    number_of_lines = ruby_snippet.number_of_lines
    lines[index, number_of_lines] = ruby_snippet.corrected_text_with_indent
  end

  lines.join
end