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



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

def checkable_layout(_node)
  true
end

#deltas(first_pair, prev_pair, current_pair) ⇒ Object



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

def deltas(first_pair, prev_pair, current_pair)
  if current_pair.loc.line == prev_pair.loc.line
    {}
  else
    { key: first_pair.loc.column - current_pair.loc.column }
  end
end

#deltas_for_first_pair(*_) ⇒ Object



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

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