Class: RuboCop::MagicComment::VimComment

Inherits:
EditorComment show all
Defined in:
lib/rubocop/magic_comment.rb

Overview

Wrapper for Vim style magic comments.

Examples:

Vim style comment

comment = RuboCop::MagicComment.parse(
  '# vim: filetype=ruby, fileencoding=ascii-8bit'
)

comment.encoding # => 'ascii-8bit'

Constant Summary collapse

FORMAT =
/#\s*vim:\s*(.+)/
SEPARATOR =
', '.freeze
OPERATOR =
'='.freeze

Constants inherited from RuboCop::MagicComment

TOKEN

Instance Method Summary collapse

Methods inherited from RuboCop::MagicComment

#frozen_string_literal?, #frozen_string_literal_specified?, #initialize, parse

Constructor Details

This class inherits a constructor from RuboCop::MagicComment

Instance Method Details

#encodingObject

For some reason the fileencoding keyword only works if there is at least one other token included in the string. For example

# works
  # vim: foo=bar, fileencoding=ascii-8bit

# does nothing
  # vim: foo=bar, fileencoding=ascii-8bit


158
159
160
# File 'lib/rubocop/magic_comment.rb', line 158

def encoding
  match('fileencoding') if tokens.size > 1
end

#frozen_string_literalObject

Vim comments cannot specify frozen string literal behavior.



163
# File 'lib/rubocop/magic_comment.rb', line 163

def frozen_string_literal; end