Class: RDocRuboCop::Lang::Ruby::Comment
- Inherits:
-
Base::Comment
- Object
- Base::Comment
- RDocRuboCop::Lang::Ruby::Comment
- Defined in:
- lib/rdoc_rubocop/lang/ruby/comment.rb
Instance Attribute Summary collapse
-
#comment_tokens ⇒ Object
readonly
Returns the value of attribute comment_tokens.
-
#source_file ⇒ Object
readonly
Returns the value of attribute source_file.
Instance Method Summary collapse
- #corrected_text ⇒ Object
-
#initialize(comment_tokens, source_file = nil) ⇒ Comment
constructor
A new instance of Comment.
- #lineno ⇒ Object
- #number_of_lines ⇒ Object
Methods inherited from Base::Comment
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_tokens ⇒ Object (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_file ⇒ Object (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_text ⇒ Object
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 |
#lineno ⇒ Object
25 26 27 |
# File 'lib/rdoc_rubocop/lang/ruby/comment.rb', line 25 def lineno @lineno ||= @comment_tokens.map(&:lineno).minmax end |
#number_of_lines ⇒ Object
29 30 31 |
# File 'lib/rdoc_rubocop/lang/ruby/comment.rb', line 29 def number_of_lines lineno[1] - lineno[0] + 1 end |