class RuboCop::AST::PairNode

to all ‘pair` nodes within RuboCop.
node when the builder constructs the AST, making its methods available
A node extension for `pair` nodes. This will be used in place of a plain

def colon?

Returns:
  • (Boolean) - whether this `pair` uses a colon delimiter
def colon?
  loc.operator.is?(COLON)
end

def delimiter(*deprecated, with_spacing: deprecated.first)

Returns:
  • (String) - the delimiter of the `pair`

Parameters:
  • with_spacing (Boolean) -- whether to include spacing
def delimiter(*deprecated, with_spacing: deprecated.first)
  if with_spacing
    hash_rocket? ? SPACED_HASH_ROCKET : SPACED_COLON
  else
    hash_rocket? ? HASH_ROCKET : COLON
  end
end

def hash_rocket?

Returns:
  • (Boolean) - whether this `pair` uses a hash rocket delimiter
def hash_rocket?
  loc.operator.is?(HASH_ROCKET)
end

def inverse_delimiter(*deprecated, with_spacing: deprecated.first)

Returns:
  • (String) - the inverse delimiter of the `pair`

Parameters:
  • with_spacing (Boolean) -- whether to include spacing
def inverse_delimiter(*deprecated, with_spacing: deprecated.first)
  if with_spacing
    hash_rocket? ? SPACED_COLON : SPACED_HASH_ROCKET
  else
    hash_rocket? ? COLON : HASH_ROCKET
  end
end

def value_on_new_line?

Returns:
  • (Boolean) - whether the value in the `pair` starts its own line
def value_on_new_line?
  key.loc.line != value.loc.line
end