class RuboCop::Cop::HashAlignmentStyles::TableAlignment

Handles calculation of deltas when the enforced style is ‘table’.

def deltas_for_first_pair(first_pair)

def deltas_for_first_pair(first_pair)
  separator_delta = separator_delta(first_pair, first_pair, 0)
  {
    separator: separator_delta,
    value: value_delta(first_pair, first_pair) - separator_delta
  }
end

def hash_rocket_delta(first_pair, current_pair)

def hash_rocket_delta(first_pair, current_pair)
  first_pair.loc.column + max_key_width(first_pair.parent) + 1 -
    current_pair.loc.operator.column
end

def key_delta(first_pair, current_pair)

def key_delta(first_pair, current_pair)
  first_pair.key_delta(current_pair)
end

def max_delimiter_width(hash_node)

def max_delimiter_width(hash_node)
  hash_node.pairs.map { |pair| pair.delimiter(true).length }.max
end

def max_key_width(hash_node)

def max_key_width(hash_node)
  hash_node.keys.map { |key| key.source.length }.max
end

def value_delta(first_pair, current_pair)

def value_delta(first_pair, current_pair)
  correct_value_column = first_pair.key.loc.column +
                         max_key_width(first_pair.parent) +
                         max_delimiter_width(first_pair.parent)
  current_pair.value_omission? ? 0 : correct_value_column - current_pair.value.loc.column
end