Class: Less2Sass::Less::Tree::OperationNode
- Defined in:
- lib/less2sass/less/tree/operation_node.rb
Overview
Node representing the operation with 2 operands.
Converts to Sass::Script::Tree::Operation.
Constant Summary collapse
- OPERATORS =
A hash from operator strings to the corresponding token types.
Copied from Sass’ lexer
{ '+' => :plus, '-' => :minus, '*' => :times, '/' => :div, '%' => :mod, '=' => :single_eq, ':' => :colon, '(' => :lparen, ')' => :rparen, ',' => :comma, 'and' => :and, 'or' => :or, 'not' => :not, '==' => :eq, '!=' => :neq, '>=' => :gte, '<=' => :lte, '>' => :gt, '<' => :lt, '#{' => :begin_interpolation, '}' => :end_interpolation, ';' => :semicolon, '{' => :lcurly, '...' => :splat }.freeze
Instance Attribute Summary collapse
-
#isSpaced ⇒ Object
Returns the value of attribute isSpaced.
-
#op ⇒ Object
Returns the value of attribute op.
-
#operands ⇒ Object
Returns the value of attribute operands.
Attributes inherited from Node
#children, #has_children, #has_parent, #line, #parent, #ref_vars
Instance Method Summary collapse
-
#sass_operator(op = @op) ⇒ Symbol
Returns the sass operator symbol, that is used internally.
- #to_s ⇒ Object
- #to_sass ⇒ Object
Methods inherited from Node
#<<, #==, #contains_variables?, #creates_context?, #each, #get_referenced_variable_names, #initialize, #transform
Constructor Details
This class inherits a constructor from Less2Sass::Less::Tree::Node
Instance Attribute Details
#isSpaced ⇒ Object
Returns the value of attribute isSpaced.
10 11 12 |
# File 'lib/less2sass/less/tree/operation_node.rb', line 10 def isSpaced @isSpaced end |
#op ⇒ Object
Returns the value of attribute op.
8 9 10 |
# File 'lib/less2sass/less/tree/operation_node.rb', line 8 def op @op end |
#operands ⇒ Object
Returns the value of attribute operands.
9 10 11 |
# File 'lib/less2sass/less/tree/operation_node.rb', line 9 def operands @operands end |
Instance Method Details
#sass_operator(op = @op) ⇒ Symbol
Returns the sass operator symbol, that is used internally.
56 57 58 59 |
# File 'lib/less2sass/less/tree/operation_node.rb', line 56 def sass_operator(op = @op) raise Less2Sass::OperatorConversionError, op unless OPERATORS[op] OPERATORS[op] end |
#to_s ⇒ Object
12 13 14 |
# File 'lib/less2sass/less/tree/operation_node.rb', line 12 def to_s @operands[0].to_s + @op + @operands[1].to_s end |
#to_sass ⇒ Object
17 18 19 |
# File 'lib/less2sass/less/tree/operation_node.rb', line 17 def to_sass node(::Sass::Script::Tree::Operation.new(@operands[0].to_sass, @operands[1].to_sass, sass_operator), line) end |