Class: CssCompare::Engine

Inherits:
Object
  • Object
show all
Defined in:
lib/css_compare/engine.rb

Overview

The engine responsible for the CSS comparison

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Engine

Returns a new instance of Engine.



6
7
8
9
# File 'lib/css_compare/engine.rb', line 6

def initialize(options)
  @options = options
  @operands = []
end

Instance Method Details

#equal?Boolean

Checks, whether the parsed CSS files are equal.

The CSS files are equal, if they define the same components, that are also equal and at the same time, no component is missing from either of the files.

Returns:

  • (Boolean)


27
28
29
# File 'lib/css_compare/engine.rb', line 27

def equal?
  @operands.first == @operands.last
end

#parse!Engine

Parses and evaluates the input CSS stylesheets - the operands.

Returns:

  • (Engine)

    itself for method chaining purposes



14
15
16
17
# File 'lib/css_compare/engine.rb', line 14

def parse!
  @options[:operands].each { |operand| @operands << CSS::Engine.new(operand).evaluate }
  self
end