Class: RDocRuboCop::Lang::Ruby::Comment

Inherits:
Base::Comment show all
Defined in:
lib/rdoc_rubocop/lang/ruby/comment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base::Comment

#rdoc, #source_codes

Constructor Details

#initialize(comment_tokens, source_file = nil) ⇒ Comment

Returns a new instance of Comment.



13
14
15
16
# 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

Instance Attribute Details

#comment_tokensObject (readonly)

Returns the value of attribute comment_tokens.



10
11
12
# File 'lib/rdoc_rubocop/lang/ruby/comment.rb', line 10

def comment_tokens
  @comment_tokens
end

#source_fileObject (readonly)

Returns the value of attribute source_file.



11
12
13
# File 'lib/rdoc_rubocop/lang/ruby/comment.rb', line 11

def source_file
  @source_file
end

Instance Method Details

#corrected_textObject



18
19
20
21
22
23
# File 'lib/rdoc_rubocop/lang/ruby/comment.rb', line 18

def corrected_text
  rdoc.
    apply.
    gsub(/^/, indent_and_commentchar).
    gsub(/ *$/, "")
end

#linenoObject



25
26
27
# File 'lib/rdoc_rubocop/lang/ruby/comment.rb', line 25

def lineno
  @lineno ||= @comment_tokens.map(&:lineno).minmax
end

#number_of_linesObject



29
30
31
# File 'lib/rdoc_rubocop/lang/ruby/comment.rb', line 29

def number_of_lines
  lineno[1] - lineno[0] + 1
end