Class: CssCompare::CSS::Component::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/css_compare/css/component/base.rb

Instance Method Summary collapse

Instance Method Details

#==(this, that) ⇒ Boolean

Checks, whether two hashes are equal.

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

Parameters:

  • this (Hash)

    first hash to compare

  • that (Hash)

    second hash to compare

Returns:

  • (Boolean)


13
14
15
16
# 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) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
# 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