2008-10-12 19:03:06 -07: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-12 19:03:06 -07: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-07 23:09:17 -07:00
|
|
|
|
2008-06-01 15:10:02 -07:00
|
|
|
def inspect
|
|
|
|
"(#{@operator.inspect} #{@operand1.inspect} #{@operand2.inspect})"
|
|
|
|
end
|
|
|
|
|
2008-10-12 20:26:56 -07: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 10:16:10 -07: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
|