class RuboCop::Cop::HashAlignment::TableAlignment
Handles calculation of deltas when the enforced style is ‘table’.
def deltas_for_first_pair(first_pair, node)
def deltas_for_first_pair(first_pair, node) self.max_key_width = node.keys.map { |key| key.source.length }.max 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 + 1 - current_pair.loc.operator.column end
def initialize
def initialize self.max_key_width = 0 end
def key_delta(first_pair, current_pair)
def key_delta(first_pair, current_pair) first_pair.key_delta(current_pair) end
def value_delta(first_pair, current_pair)
def value_delta(first_pair, current_pair) return 0 if current_pair.kwsplat_type? correct_value_column = first_pair.key.loc.column + current_pair.delimiter(true).length + max_key_width correct_value_column - current_pair.value.loc.column end