module Rubocop::Cop::Util

This module contains a collection of useful utility methods.

Public Instance Methods

block_length(block_node) click to toggle source
# File lib/rubocop/cop/util.rb, line 22
def block_length(block_node)
  block_node.loc.end.line - block_node.loc.begin.line
end
strip_quotes(str) click to toggle source
# File lib/rubocop/cop/util.rb, line 9
def strip_quotes(str)
  if str[0] == '"' || str[0] == "'"
    str[0] = ''
    str[-1] = ''
  else
    # we're dealing with %q or %Q
    str[0, 3] = ''
    str[-1] = ''
  end

  str
end