Class: RuboCop::Cop::Style::AlignHash::AlignmentOfValues
- Inherits:
-
Object
- Object
- RuboCop::Cop::Style::AlignHash::AlignmentOfValues
show all
- Includes:
- HashNode
- Defined in:
- lib/rubocop/cop/style/align_hash.rb
Overview
Common functionality for the styles where not only keys, but also values are aligned.
Instance Method Summary
collapse
Methods included from HashNode
#any_pairs_on_the_same_line?
Instance Method Details
#checkable_layout(node) ⇒ Object
35
36
37
|
# File 'lib/rubocop/cop/style/align_hash.rb', line 35
def checkable_layout(node)
!any_pairs_on_the_same_line?(node) && all_have_same_separator?(node)
end
|
#deltas(first_pair, current_pair) ⇒ Object
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/rubocop/cop/style/align_hash.rb', line 39
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
|