Class: RuboCop::MagicComment::EditorComment Abstract

Inherits:
RuboCop::MagicComment 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

Constant Summary

Constants inherited from RuboCop::MagicComment

KEYWORDS, TOKEN

Instance Method Summary collapse

Methods inherited from RuboCop::MagicComment

#any?, #encoding_specified?, #frozen_string_literal, #frozen_string_literal?, #frozen_string_literal_specified?, #initialize, parse, #shareable_constant_value, #shareable_constant_value_specified?, #valid?, #valid_literal_value?, #valid_shareable_constant_value?

Constructor Details

This class inherits a constructor from RuboCop::MagicComment

Instance Method Details

#encodingObject


123
124
125
# File 'lib/rubocop/magic_comment.rb', line 123

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

#without(type) ⇒ Object

Rewrite the comment without a given token type


128
129
130
131
132
133
# File 'lib/rubocop/magic_comment.rb', line 128

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