class RDocRuboCop::Lang::Ruby::Comment

Attributes

comment_tokens[R]
source_file[R]

Public Class Methods

new(comment_tokens, source_file = nil) click to toggle source
# File lib/rdoc_rubocop/lang/ruby/comment.rb, line 13
def initialize(comment_tokens, source_file = nil)
  @comment_tokens = comment_tokens
  @source_file = source_file
end

Public Instance Methods

corrected_text() click to toggle source
# File lib/rdoc_rubocop/lang/ruby/comment.rb, line 18
def corrected_text
  rdoc.
    apply.
    gsub(/^/, indent_and_commentchar).
    gsub(/ *$/, "")
end
lineno() click to toggle source
# File lib/rdoc_rubocop/lang/ruby/comment.rb, line 25
def lineno
  @lineno ||= @comment_tokens.map(&:lineno).minmax
end
number_of_lines() click to toggle source
# File lib/rdoc_rubocop/lang/ruby/comment.rb, line 29
def number_of_lines
  lineno[1] - lineno[0] + 1
end

Private Instance Methods

indent_and_commentchar() click to toggle source
# File lib/rdoc_rubocop/lang/ruby/comment.rb, line 39
def indent_and_commentchar
  indent = " " * @comment_tokens.map(&:column).min
  commentchar_and_indent = text.scan(/^# *(?=\S)/).min

  "#{indent}#{commentchar_and_indent}"
end
text() click to toggle source
# File lib/rdoc_rubocop/lang/ruby/comment.rb, line 46
def text
  @text ||= @comment_tokens.map(&:token).join
end
text_without_commentchar() click to toggle source
# File lib/rdoc_rubocop/lang/ruby/comment.rb, line 35
def text_without_commentchar
  text.gsub(/^ *#/, "").strip_indent
end