class CssCompare::CSS::Component::Base

Public Instance Methods

==(this, that) click to toggle source

Checks, whether two hashes are equal.

They are equal, if they contain the same keys and also have the same values assigned.

@param [Hash] this first hash to compare @param [Hash] that second hash to compare @return [Boolean]

# File lib/css_compare/css/component/base.rb, line 13
def ==(this, that)
  keys = merge_keys(this, that)
  keys.all? { |key| this[key] && that[key] && this[key] == that[key] }
end
equals?(this, that) click to toggle source
# File lib/css_compare/css/component/base.rb, line 18
def equals?(this, that)
  keys = merge_keys(this, that)
  keys.all? { |key| this[key] && that[key] && this[key].equals?(that[key]) }
end

Private Instance Methods

merge_keys(this, that) click to toggle source
# File lib/css_compare/css/component/base.rb, line 25
def merge_keys(this, that)
  keys = this.keys + that.keys
  keys.uniq
end