Class: Less2Sass::Less::Tree::KeywordNode

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

Overview

Represents the CSS property names and a little bit more.

It can represent the name of a CSS rule, or it can be a part of a variable definition’s value.

In the latter case its Sass equivalents are:

- {::Sass::Script::Value::Bool}
- {::Sass::Script::Value::Null}

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

#valueObject

Returns the value of attribute value.



15
16
17
# File 'lib/less2sass/less/tree/keyword_node.rb', line 15

def value
  @value
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/less2sass/less/tree/keyword_node.rb', line 21

def empty?
  @value.empty?
end

#to_sObject



17
18
19
# File 'lib/less2sass/less/tree/keyword_node.rb', line 17

def to_s
  @value.to_s
end

#to_sass::Sass::Script::Value::Base

Returns a SassScript Value node.

Usually will be called in case of a variable definition and its parent node would be a ExpressionNode, which would wrap it up into a Sass::Script::Tree::Literal.

Returns:

  • (::Sass::Script::Value::Base)

Raises:

  • FeatureConversionError if this node’s value is not expected.

See Also:



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/less2sass/less/tree/keyword_node.rb', line 35

def to_sass
  case @value
  when 'true' then ::Sass::Script::Value::Bool.new(true)
  when 'false' then ::Sass::Script::Value::Bool.new(false)
  when 'null' then ::Sass::Script::Value::Null.new
  else
    raise FeatureConversionError, self unless @value.respond_to?(:to_s)
    string = ::Sass::Script::Value::String.new(@value.to_s)
    node(::Sass::Script::Tree::Literal.new(string), line)
  end
end