Class: Less2Sass::Less::Tree::QuotedNode

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

Overview

Represents a single or double-quoted string in Less.

The Sass equivalent is a Sass::Script::Value::String 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.



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

def currentFileInfo
  @currentFileInfo
end

#escapedObject

Returns the value of attribute escaped.



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

def escaped
  @escaped
end

#indexObject

Returns the value of attribute index.



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

def index
  @index
end

#quoteObject

Returns the value of attribute quote.



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

def quote
  @quote
end

#valueObject

Returns the value of attribute value.



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

def value
  @value
end

Instance Method Details

#string_interpolation?(value = @value) ⇒ Boolean

Checks, whether the quoted string contains an interpolation.

Returns:

  • (Boolean)


40
41
42
# File 'lib/less2sass/less/tree/quoted_node.rb', line 40

def string_interpolation?(value = @value)
  !value.index(INTERPOLATION).nil?
end

#to_sObject

Returns the string’s raw value without passing the type of quote.

Sass has its own standards regarding the quotes, it should be in Sass’ competences to choose what type of quote to use.



33
34
35
# File 'lib/less2sass/less/tree/quoted_node.rb', line 33

def to_s
  @value
end

#to_sass::Sass::Script::Tree::Literal, ::Sass::Script::Tree::StringInterpolation

Returns the Sass equivalent for a quoted string.

Returns:

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

    simple string literal

  • (::Sass::Script::Tree::StringInterpolation)

    interpolation node, if the string contains interpolations

See Also:



21
22
23
24
25
26
27
# File 'lib/less2sass/less/tree/quoted_node.rb', line 21

def to_sass
  if string_interpolation?
    interpolation_node(@value)
  else
    node(::Sass::Script::Tree::Literal.new(::Sass::Script::Value::String.new(@value, :string)), line)
  end
end