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(/\#* \b(?:en)?coding: (#{TOKEN})/i) end
def extract_frozen_string_literal
- See: https://git.io/vM7Mg -
def extract_frozen_string_literal extract(/\A#\s*frozen[_-]string[_-]literal:\s*(#{TOKEN})\s*\z/i) end