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

#encodingObject



149
150
151
# File 'lib/rubocop/magic_comment.rb', line 149

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

#without(type) ⇒ Object

Rewrite the comment without a given token type



154
155
156
157
158
159
# File 'lib/rubocop/magic_comment.rb', line 154

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