Class: RuboCop::Cop::Style::AlignHash::KeyAlignment
- Inherits:
-
Object
- Object
- RuboCop::Cop::Style::AlignHash::KeyAlignment
- 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
- #checkable_layout(_node) ⇒ Object
- #deltas(first_pair, prev_pair, current_pair) ⇒ Object
- #deltas_for_first_pair ⇒ Object
Instance Method Details
#checkable_layout(_node) ⇒ Object
14 15 16 |
# File 'lib/rubocop/cop/style/align_hash.rb', line 14 def checkable_layout(_node) true end |
#deltas(first_pair, prev_pair, current_pair) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/rubocop/cop/style/align_hash.rb', line 22 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
18 19 20 |
# File 'lib/rubocop/cop/style/align_hash.rb', line 18 def deltas_for_first_pair(*) {} # The first pair is always considered correct. end |