Module: Rubocop::Cop::Util

Defined in:
lib/rubocop/cop/util.rb

Class Method Summary collapse

Class Method Details

.block_length(block_node) ⇒ Object



21
22
23
# File 'lib/rubocop/cop/util.rb', line 21

def block_length(block_node)
  block_node.loc.end.line - block_node.loc.begin.line
end

.strip_quotes(str) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/rubocop/cop/util.rb', line 8

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