class RuboCop::Cop::Style::AlignHash::SeparatorAlignment
Handles calculation of deltas when the enforced style is 'separator'.
Public Instance Methods
deltas_for_first_pair(*)
click to toggle source
# File lib/rubocop/cop/style/align_hash.rb, line 113 def deltas_for_first_pair(*) {} # The first pair is always considered correct. end
Private Instance Methods
hash_rocket_delta(first_pair, current_separator)
click to toggle source
# File lib/rubocop/cop/style/align_hash.rb, line 128 def hash_rocket_delta(first_pair, current_separator) first_pair.loc.operator.column - current_separator.column end
key_delta(first_pair, current_pair)
click to toggle source
# File lib/rubocop/cop/style/align_hash.rb, line 119 def key_delta(first_pair, current_pair) key_end_column(first_pair) - key_end_column(current_pair) end
key_end_column(pair)
click to toggle source
# File lib/rubocop/cop/style/align_hash.rb, line 123 def key_end_column(pair) key, _value = *pair key.loc.column + key.source.length end
value_delta(first_pair, current_pair)
click to toggle source
# File lib/rubocop/cop/style/align_hash.rb, line 132 def value_delta(first_pair, current_pair) _, first_value = *first_pair _, current_value = *current_pair first_value.loc.column - current_value.loc.column end