Class: Less2Sass::Less::Tree::DimensionNode

Inherits:
Node
  • Object
show all
Defined in:
lib/less2sass/less/tree/dimension_node.rb

Overview

Representation of a number and a unit. The Sass equivalent is the Sass::Script::Value::Number or Sass::Script::Tree::Literal if the dimension is a part of an ExpressionNode‘s OperationNode.

Instance Attribute Summary collapse

Attributes inherited from Node

#children, #has_children, #has_parent, #line, #parent, #ref_vars

Instance Method Summary collapse

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

#unitObject

Returns the value of attribute unit.



10
11
12
# File 'lib/less2sass/less/tree/dimension_node.rb', line 10

def unit
  @unit
end

#valueObject

Returns the value of attribute value.



9
10
11
# File 'lib/less2sass/less/tree/dimension_node.rb', line 9

def value
  @value
end

Instance Method Details

#to_sObject



20
21
22
# File 'lib/less2sass/less/tree/dimension_node.rb', line 20

def to_s
  @value.to_s + @unit.to_s
end

#to_sassObject

See Also:



13
14
15
16
17
18
# File 'lib/less2sass/less/tree/dimension_node.rb', line 13

def to_sass
  numerator = @unit.is_a?(UnitNode) ? @unit.numerator : @unit['numerator']
  denominator = @unit.is_a?(UnitNode) ? @unit.denominator : @unit['denominator']
  dimension = ::Sass::Script::Value::Number.new(@value, numerator, denominator)
  node(::Sass::Script::Tree::Literal.new(dimension), line)
end