Class: RuboCop::MagicComment::EmacsComment

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


Wrapper for Emacs style magic comments.


Emacs style comment

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

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

See Also:

Constant Summary

::RuboCop::MagicComment - Inherited


Class Method Summary

::RuboCop::MagicComment - Inherited


Detect magic comment format and pass it to the appropriate wrapper.

Instance Attribute Summary

::RuboCop::MagicComment - Inherited

#any?, #encoding_specified?,

Does the magic comment enable the frozen string literal feature.


Was a magic comment for the frozen string literal found?


Was a shareable_constant_value specified?


Was the Sorbet typed sigil specified?

#valid?, #valid_literal_value?, #valid_shareable_constant_value?

Instance Method Summary

EditorComment - Inherited


Rewrite the comment without a given token type.


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


Individual tokens composing an editor specific comment string.

::RuboCop::MagicComment - Inherited


Expose the frozen_string_literal value coerced to a boolean if possible.


Expose the shareable_constant_value value coerced to a boolean if possible.


Match the entire comment string with a pattern and take the first capture.


Constructor Details

This class inherits a constructor from RuboCop::MagicComment

Instance Method Details

#extract_frozen_string_literal (private)

[ GitHub ]

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

def extract_frozen_string_literal

#extract_shareable_constant_value (private)

[ GitHub ]

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

def extract_shareable_constant_value

#extract_typed (private)

Emacs comments cannot specify Sorbet typechecking behavior.

[ GitHub ]

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

def extract_typed; end