Class: RuboCop::Cop::HashAlignment::TableAlignment

Inherits:
Object
  • Object
show all
Includes:
ValueAlignment
Defined in:
lib/rubocop/cop/mixin/hash_alignment.rb

Overview

Handles calculation of deltas when the enforced style is ‘table’.

Instance Method Summary collapse

Methods included from ValueAlignment

#checkable_layout?, #deltas

Instance Method Details

#deltas_for_first_pair(first_pair, node) ⇒ Object



86
87
88
89
90
91
92
93
94
# File 'lib/rubocop/cop/mixin/hash_alignment.rb', line 86

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