Class: RuboCop::Cop::HashAlignmentStyles::TableAlignment
- Inherits:
-
Object
- Object
- RuboCop::Cop::HashAlignmentStyles::TableAlignment
- Includes:
- ValueAlignment
- Defined in:
- lib/rubocop/cop/mixin/hash_alignment_styles.rb
Overview
Handles calculation of deltas when the enforced style is ‘table’.
Instance Method Summary collapse
- #deltas_for_first_pair(first_pair, node) ⇒ Object
-
#initialize ⇒ TableAlignment
constructor
A new instance of TableAlignment.
Methods included from ValueAlignment
Constructor Details
#initialize ⇒ TableAlignment
Returns a new instance of TableAlignment.
84 85 86 |
# File 'lib/rubocop/cop/mixin/hash_alignment_styles.rb', line 84 def initialize self.max_key_width = 0 end |
Instance Method Details
#deltas_for_first_pair(first_pair, node) ⇒ Object
88 89 90 91 92 93 94 95 96 |
# File 'lib/rubocop/cop/mixin/hash_alignment_styles.rb', line 88 def deltas_for_first_pair(first_pair, node) self.max_key_width = node.keys.map { |key| key.source.length }.max separator_delta = separator_delta(first_pair, first_pair, 0) { separator: separator_delta, value: value_delta(first_pair, first_pair) - separator_delta } end |