Class: Sass::Script::Operation
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(operand1, operand2, operator) ⇒ Operation
constructor
A new instance of Operation.
- #inspect ⇒ Object
- #perform(environment) ⇒ Object
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
#inspect ⇒ Object
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 |