Files

Class/Module Index [+]

Quicksearch

RuboCop::Cop::Style::AlignHash::TableAlignment

Handles calculation of deltas when the enforced style is 'table'.

Public Instance Methods

deltas_for_first_pair(first_pair, node) click to toggle source

The table style is the only one where the first key-value pair can be considered to have bad alignment.

# File lib/rubocop/cop/style/align_hash.rb, line 78
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

[Validate]

Generated with the Darkfish Rdoc Generator 2.