123456789_123456789_123456789_123456789_123456789_

Class: RuboCop::MagicComment::EmacsComment

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, EditorComment, MagicComment
Instance Chain:
self, EditorComment, MagicComment
Inherits: RuboCop::MagicComment::EditorComment
Defined in: lib/rubocop/magic_comment.rb

Overview

Wrapper for Emacs style magic comments.

Examples:

Emacs style comment

comment = RuboCop::MagicComment.parse(
  '# -*- encoding: ASCII-8BIT -*-'
)

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

See Also:

Constant Summary

Instance Method Summary

EditorComment - Inherited

#encoding,
#without

Rewrite the comment without a given token type.

#match

Find a token starting with the provided keyword and extract its value.

#tokens

Individual tokens composing an editor specific comment string.

Instance Method Details

#extract_frozen_string_literal (private)

[ GitHub ]

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

def extract_frozen_string_literal
  match(KEYWORDS[:frozen_string_literal])
end

#extract_rbs_inline_value (private)

Emacs comments cannot specify RBS::inline behavior.

[ GitHub ]

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

def extract_rbs_inline_value; end

#extract_shareable_constant_value (private)

[ GitHub ]

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

def extract_shareable_constant_value
  match(KEYWORDS[:shareable_constant_value])
end

#extract_typed (private)

Emacs comments cannot specify Sorbet typechecking behavior.

[ GitHub ]

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

def extract_typed; end

#new_frozen_string_literal(value)

[ GitHub ]

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

def new_frozen_string_literal(value)
  "# -*- frozen_string_literal: #{value} -*-"
end