Checks for uses of the character literal ?x.
# File lib/rubocop/cop/style/character_literal.rb, line 17 def autocorrect(node) @corrections << lambda do |corrector| string = node.loc.expression.source[1..-1] if string.length == 1 # normal character corrector.replace(node.loc.expression, "'#{string}'") elsif string.length == 2 # special character like \n corrector.replace(node.loc.expression, %("#{string}")) end end end
Dummy implementation of method in ConfigurableEnforcedStyle that is called from StringHelp.
# File lib/rubocop/cop/style/character_literal.rb, line 36 def correct_style_detected end
# File lib/rubocop/cop/style/character_literal.rb, line 11 def offense?(node) # we don't register an offense for things like ?\C-\M-d node.loc.begin.is?('?') && node.loc.expression.source.size.between?(2, 3) end
Dummy implementation of method in ConfigurableEnforcedStyle that is called from StringHelp.
# File lib/rubocop/cop/style/character_literal.rb, line 31 def opposite_style_detected end
Generated with the Darkfish Rdoc Generator 2.