module RuboCop::AST::HashElementNode

def delimiter_delta(other)

Returns:
  • (Integer) - the delta between the two delimiters

Other tags:
    Note: - Pairs with different delimiter styles return a delta of 0
def delimiter_delta(other)
  HashElementDelta.new(self, other).delimiter_delta
end

def key

Returns:
  • (Node) - the key of the hash element

Other tags:
    Note: - For keyword splats, this returns the whole node
def key
  node_parts[0]
end

def key_delta(other, alignment = :left)

Returns:
  • (Integer) - the delta between the two keys

Parameters:
  • alignment (Symbol) -- whether to check the left or right side

Other tags:
    Note: - Keyword splats always return a delta of 0 for right alignment
    Note: - Keys on the same line always return a delta of 0
def key_delta(other, alignment = :left)
  HashElementDelta.new(self, other).key_delta(alignment)
end

def same_line?(other)

Returns:
  • (Boolean) - whether this element is on the same line as `other`

Other tags:
    Note: - A multiline element is considered to be on the same line if it
def same_line?(other)
  loc.last_line == other.loc.line || loc.line == other.loc.last_line
end

def value

Returns:
  • (Node) - the value of the hash element

Other tags:
    Note: - For keyword splats, this returns the whole node
def value
  node_parts[1]
end

def value_delta(other)

Returns:
  • (Integer) - the delta between the two values

Other tags:
    Note: - Keyword splats always return a delta of 0
def value_delta(other)
  HashElementDelta.new(self, other).value_delta
end