Class: RuboCop::Cop::Style::AlignHash::TableAlignment
- Inherits:
-
AlignmentOfValues
- Object
- AlignmentOfValues
- RuboCop::Cop::Style::AlignHash::TableAlignment
- Defined in:
- lib/rubocop/cop/style/align_hash.rb
Overview
Handles calculation of deltas when the enforced style is 'table'.
Instance Method Summary collapse
-
#deltas_for_first_pair(first_pair, node) ⇒ Object
The table style is the only one where the first key-value pair can be considered to have bad alignment.
Methods inherited from AlignmentOfValues
Instance Method Details
#deltas_for_first_pair(first_pair, node) ⇒ Object
The table style is the only one where the first key-value pair can be considered to have bad alignment.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/rubocop/cop/style/align_hash.rb', line 79 def deltas_for_first_pair(first_pair, node) key_widths = node.children.map do |pair| key, _value = *pair key.loc.expression.source.length end @max_key_width = key_widths.max separator_delta = separator_delta(first_pair, first_pair.loc.operator, 0) { separator: separator_delta, value: value_delta(first_pair, first_pair) - separator_delta } end |