Class: Less2Sass::Less::Tree::AnonymousNode

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

Overview

Represents a CSS literal in Less.

Its Sass equivalent is Sass::Script::Value::Base wrapped in Sass::Script::Tree::Literal.

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

#currentFileInfoObject

Returns the value of attribute currentFileInfo.



12
13
14
# File 'lib/less2sass/less/tree/anonymous_node.rb', line 12

def currentFileInfo
  @currentFileInfo
end

#indexObject

Returns the value of attribute index.



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

def index
  @index
end

#mapLinesObject

Returns the value of attribute mapLines.



11
12
13
# File 'lib/less2sass/less/tree/anonymous_node.rb', line 11

def mapLines
  @mapLines
end

#rulesetLikeObject

Returns the value of attribute rulesetLike.



13
14
15
# File 'lib/less2sass/less/tree/anonymous_node.rb', line 13

def rulesetLike
  @rulesetLike
end

#valueObject

Returns the value of attribute value.



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

def value
  @value
end

Instance Method Details

#to_sass::Sass::Script::Tree::Literal

Note:

Never seen a different equivalent than String or a Number but can’t be sure.

Converts to a Sass::Script::Tree::Literal that encapsulates a Sass::Script::Value::Base.

Returns:

  • (::Sass::Script::Tree::Literal)

Raises:

  • FeatureConversionError if ‘@value` not a String or a Numeric.

See Also:



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/less2sass/less/tree/anonymous_node.rb', line 24

def to_sass
  subnode ||=
    begin
      if @value.is_a?(String)
        # Always an :identifier - the default value of the 2nd param
        ::Sass::Script::Value::String.new(@value)
      elsif @value.is_a?(Numeric)
        # Anonymous nodes do not have a numerator nor a denominator
        ::Sass::Script::Value::Number.new(@value)
      else
        raise FeatureConversionError, self
      end
    end
  return subnode if subnode.is_a?(::Sass::Script::Tree::Literal)
  node(::Sass::Script::Tree::Literal.new(subnode), line)
end