Class: RuboCop::MagicComment::EditorComment Abstract

Inherits:
MagicComment
  • Object
show all
Defined in:
lib/rubocop/magic_comment.rb

Overview

This class is abstract.

Parent to Vim and Emacs magic comment handling.

Direct Known Subclasses

EmacsComment, VimComment

Instance Method Summary collapse

Instance Method Details

#encoding ⇒ Object



165
166
167
# File 'lib/rubocop/magic_comment.rb', line 165

def encoding
  match(self.class::KEYWORDS[:encoding])
end

#without(type) ⇒ Object

Rewrite the comment without a given token type



170
171
172
173
174
175
# File 'lib/rubocop/magic_comment.rb', line 170

def without(type)
  remaining = tokens.grep_v(/\A#{self.class::KEYWORDS[type.to_sym]}/)
  return '' if remaining.empty?

  self.class::FORMAT % remaining.join(self.class::SEPARATOR)
end