class RubbyCop::MagicComment::VimComment

Wrapper for Vim style magic comments.

@example Vim style comment

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

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

Constants

FORMAT
OPERATOR
SEPARATOR

Public Instance Methods

encoding() click to toggle source

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
# File lib/rubbycop/magic_comment.rb, line 169
def encoding
  match('fileencoding') if tokens.size > 1
end
frozen_string_literal() click to toggle source

Vim comments cannot specify frozen string literal behavior.

# File lib/rubbycop/magic_comment.rb, line 174
def frozen_string_literal; end