class RuboCop::MagicComment::SimpleComment
comment2.encoding # => ‘utf-8’
comment2.frozen_string_literal # => nil
comment2 = RuboCop::MagicComment.parse(‘# encoding: utf-8’)
@example encoding comments
comment1.encoding # => nil
comment1.frozen_string_literal # => true
comment1 = RuboCop::MagicComment.parse(‘# frozen_string_literal: true’)
@example frozen string literal comments
Simple comments can only specify one setting per comment.
Wrapper for regular magic comments not bound to an editor.
def encoding
def encoding extract(/\A\s*\#.*\b#{KEYWORDS[:encoding]}: (#{TOKEN})/io) end
def extract_frozen_string_literal
- See: https://git.io/vM7Mg -
def extract_frozen_string_literal extract(/\A\s*#\s*#{KEYWORDS[:frozen_string_literal]}:\s*(#{TOKEN})\s*\z/io) end
def extract_shareable_constant_value
def extract_shareable_constant_value extract(/\A\s*#\s*#{KEYWORDS[:shareable_constant_value]}:\s*(#{TOKEN})\s*\z/io) end
def without(type)
def without(type) if @comment.match?(/\A#\s*#{self.class::KEYWORDS[type.to_sym]}/) '' else @comment end end