2008-10-13 02:03:06 +00:00
|
|
|
require 'sass/script/string'
|
|
|
|
require 'sass/script/number'
|
|
|
|
require 'sass/script/color'
|
|
|
|
require 'sass/script/functions'
|
|
|
|
require 'sass/script/unary_operation'
|
2006-12-22 10:28:17 +00:00
|
|
|
|
2008-10-13 02:03:06 +00:00
|
|
|
module Sass::Script
|
2007-03-01 05:52:47 +00:00
|
|
|
class Operation # :nodoc:
|
2007-01-28 17:24:08 +00:00
|
|
|
def initialize(operand1, operand2, operator)
|
2006-12-23 22:32:05 +00:00
|
|
|
@operand1 = operand1
|
|
|
|
@operand2 = operand2
|
|
|
|
@operator = operator
|
2006-12-22 10:28:17 +00:00
|
|
|
end
|
2008-04-08 06:09:17 +00:00
|
|
|
|
2008-06-01 22:10:02 +00:00
|
|
|
def inspect
|
|
|
|
"(#{@operator.inspect} #{@operand1.inspect} #{@operand2.inspect})"
|
|
|
|
end
|
|
|
|
|
2008-10-13 03:26:56 +00:00
|
|
|
def perform(environment)
|
|
|
|
literal1 = @operand1.perform(environment)
|
|
|
|
literal2 = @operand2.perform(environment)
|
2006-12-23 22:32:05 +00:00
|
|
|
begin
|
|
|
|
literal1.send(@operator, literal2)
|
2006-12-23 22:57:31 +00:00
|
|
|
rescue NoMethodError => e
|
2007-02-10 02:55:55 +00:00
|
|
|
raise e unless e.name.to_s == @operator.to_s
|
2008-04-19 17:16:10 +00:00
|
|
|
raise Sass::SyntaxError.new("Undefined operation: \"#{literal1} #{@operator} #{literal2}\".")
|
2006-12-23 22:32:05 +00:00
|
|
|
end
|
2006-12-22 10:28:17 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|