Class: Sass::Script::Operation

Inherits:
Object
  • Object
show all
Defined in:
lib/sass/script/operation.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(operand1, operand2, operator) ⇒ Operation

Returns a new instance of Operation.



9
10
11
12
13
# File 'lib/sass/script/operation.rb', line 9

def initialize(operand1, operand2, operator)
  @operand1 = operand1
  @operand2 = operand2
  @operator = operator
end

Instance Method Details

#inspectObject



15
16
17
# File 'lib/sass/script/operation.rb', line 15

def inspect
  "(#{@operator.inspect} #{@operand1.inspect} #{@operand2.inspect})"
end

#perform(environment) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/sass/script/operation.rb', line 19

def perform(environment)
  literal1 = @operand1.perform(environment)
  literal2 = @operand2.perform(environment)
  begin
    literal1.send(@operator, literal2)
  rescue NoMethodError => e
    raise e unless e.name.to_s == @operator.to_s
    raise Sass::SyntaxError.new("Undefined operation: \"#{literal1} #{@operator} #{literal2}\".")
  end
end