class RuboCop::MagicComment::EditorComment
Parent to Vim and Emacs magic comment handling.
@abstract
Private Instance Methods
match(keyword)
click to toggle source
Find a token starting with the provided keyword and extract its value.
@param keyword [String]
@return [String] extracted value if it is found @return [nil] otherwise
# File lib/rubocop/magic_comment.rb, line 99 def match(keyword) pattern = /\A#{keyword}\s*#{self.class::OPERATOR}\s*(#{TOKEN})\z/ tokens.each do |token| next unless (value = token[pattern, 1]) return value.downcase end nil end
tokens()
click to toggle source
Individual tokens composing an editor specific comment string.
@return [Array<String>]
# File lib/rubocop/magic_comment.rb, line 114 def tokens extract(self.class::FORMAT).split(self.class::SEPARATOR).map(&:strip) end