123456789_123456789_123456789_123456789_123456789_

Module: RuboCop::Cop::HashAlignmentStyles::ValueAlignment

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Included In:
Defined in: lib/rubocop/cop/mixin/hash_alignment_styles.rb

Overview

Common functionality for checking alignment of hash values.

Instance Method Summary

Instance Method Details

#checkable_layout?(node) ⇒ Boolean

[ GitHub ]

  
# File 'lib/rubocop/cop/mixin/hash_alignment_styles.rb', line 57

def checkable_layout?(node)
  !node.pairs_on_same_line? && !node.mixed_delimiters?
end

#deltas(first_pair, current_pair)

[ GitHub ]

  
# File 'lib/rubocop/cop/mixin/hash_alignment_styles.rb', line 61

def deltas(first_pair, current_pair)
  key_delta = key_delta(first_pair, current_pair)
  separator_delta = separator_delta(first_pair, current_pair, key_delta)
  value_delta = value_delta(first_pair, current_pair) - key_delta - separator_delta

  { key: key_delta, separator: separator_delta, value: value_delta }
end

#separator_delta(first_pair, current_pair, key_delta) (private)

[ GitHub ]

  
# File 'lib/rubocop/cop/mixin/hash_alignment_styles.rb', line 71

def separator_delta(first_pair, current_pair, key_delta)
  if current_pair.hash_rocket?
    hash_rocket_delta(first_pair, current_pair) - key_delta
  else
    0
  end
end