Class: RuboCop::Cop::Style::AlignHash::KeyAlignment

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/cop/style/align_hash.rb

Overview

Handles calculation of deltas (deviations from correct alignment) when the enforced style is ‘key’.

Instance Method Summary collapse

Instance Method Details

#checkable_layout(_node) ⇒ Object



13
14
15
# File 'lib/rubocop/cop/style/align_hash.rb', line 13

def checkable_layout(_node)
  true
end

#deltas(first_pair, current_pair) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/rubocop/cop/style/align_hash.rb', line 21

def deltas(first_pair, current_pair)
  if Util.begins_its_line?(current_pair.source_range)
    { key: first_pair.loc.column - current_pair.loc.column }
  else
    {}
  end
end

#deltas_for_first_pairObject



17
18
19
# File 'lib/rubocop/cop/style/align_hash.rb', line 17

def deltas_for_first_pair(*)
  {} # The first pair is always considered correct.
end