class RuboCop::Cop::Style::AlignHash::AlignmentOfValues
values are aligned.
Common functionality for the styles where not only keys, but also
def all_have_same_separator?(node)
def all_have_same_separator?(node) first_separator = node.children.first.loc.operator.source node.children.butfirst.all? do |pair| pair.loc.operator.is?(first_separator) end end
def checkable_layout(node)
def checkable_layout(node) !any_pairs_on_the_same_line?(node) && all_have_same_separator?(node) end
def deltas(first_pair, current_pair)
def deltas(first_pair, current_pair) key_delta = key_delta(first_pair, current_pair) current_separator = current_pair.loc.operator separator_delta = separator_delta(first_pair, current_separator, key_delta) value_delta = value_delta(first_pair, current_pair) - key_delta - separator_delta { key: key_delta, separator: separator_delta, value: value_delta } end
def separator_delta(first_pair, current_separator, key_delta)
def separator_delta(first_pair, current_separator, key_delta) if current_separator.is?(':') 0 # Colon follows directly after key else hash_rocket_delta(first_pair, current_separator) - key_delta end end