Class: RuboCop::MagicComment::SimpleComment
- Inherits:
-
MagicComment
- Object
- MagicComment
- RuboCop::MagicComment::SimpleComment
- Defined in:
- lib/rubocop/magic_comment.rb
Overview
Wrapper for regular magic comments not bound to an editor.
Simple comments can only specify one setting per comment.
Constant Summary collapse
- FSTRING_LITERAL_COMMENT =
'frozen_string_literal:\s*(true|false)'
Instance Method Summary collapse
-
#encoding ⇒ Object
Match
encodingorcoding. - #new_frozen_string_literal(value) ⇒ Object
-
#without(type) ⇒ Object
Rewrite the comment without a given token type.
Instance Method Details
#encoding ⇒ Object
Match encoding or coding
285 286 287 |
# File 'lib/rubocop/magic_comment.rb', line 285 def encoding extract(/\A\s*\#\s*(#{FSTRING_LITERAL_COMMENT})?\s*#{KEYWORDS[:encoding]}: (#{TOKEN})/io) end |
#new_frozen_string_literal(value) ⇒ Object
298 299 300 |
# File 'lib/rubocop/magic_comment.rb', line 298 def new_frozen_string_literal(value) "# frozen_string_literal: #{value}" end |
#without(type) ⇒ Object
Rewrite the comment without a given token type
290 291 292 293 294 295 296 |
# File 'lib/rubocop/magic_comment.rb', line 290 def without(type) if @comment.match?(/\A#\s*#{self.class::KEYWORDS[type.to_sym]}/io) '' else @comment end end |