Class: Less2Sass::Less::Tree::KeywordNode
- 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
-
#value ⇒ Object
Returns the value of attribute value.
Attributes inherited from Node
#children, #has_children, #has_parent, #line, #parent, #ref_vars
Instance Method Summary collapse
- #empty? ⇒ Boolean
- #to_s ⇒ Object
-
#to_sass ⇒ ::Sass::Script::Value::Base
Returns a SassScript Value node.
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
#value ⇒ Object
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
21 22 23 |
# File 'lib/less2sass/less/tree/keyword_node.rb', line 21 def empty? @value.empty? end |
#to_s ⇒ Object
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.
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 |