Class: Sass::Script::Interpolation
- Defined in:
- lib/sass/script/interpolation.rb
Overview
A SassScript object representing #{}
interpolation outside a string.
Instance Attribute Summary
Attributes inherited from Node
Instance Method Summary collapse
-
#_perform(environment) ⇒ Sass::Script::String
protected
Evaluates the interpolation.
-
#children ⇒ Array<Node>
Returns the three components of the interpolation,
before
,mid
, andafter
. -
#initialize(before, mid, after, wb, wa, originally_text = false) ⇒ Interpolation
constructor
Interpolation in a property is of the form
before #{mid} after
. -
#inspect ⇒ String
A human-readable s-expression representation of the interpolation.
- #to_sass(opts = {})
Methods inherited from Node
Constructor Details
#initialize(before, mid, after, wb, wa, originally_text = false) ⇒ Interpolation
Interpolation in a property is of the form before #{mid} after
.
17 18 19 20 21 22 23 24 |
# File 'lib/sass/script/interpolation.rb', line 17
def initialize(before, mid, after, wb, wa, originally_text = false)
@before = before
@mid = mid
@after = after
@whitespace_before = wb
@whitespace_after = wa
@originally_text = originally_text
end
|
Instance Method Details
#_perform(environment) ⇒ Sass::Script::String (protected)
Evaluates the interpolation.
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/sass/script/interpolation.rb', line 59
def _perform(environment)
res = ""
res << @before.perform(environment).to_s if @before
res << " " if @before && @whitespace_before
val = @mid.perform(environment)
res << (val.is_a?(Sass::Script::String) ? val.value : val.to_s)
res << " " if @after && @whitespace_after
res << @after.perform(environment).to_s if @after
Sass::Script::String.new(res)
end
|
#children ⇒ Array<Node>
Returns the three components of the interpolation, before
, mid
, and after
.
49 50 51 |
# File 'lib/sass/script/interpolation.rb', line 49
def children
[@before, @mid, @after].compact
end
|
#inspect ⇒ String
Returns A human-readable s-expression representation of the interpolation.
27 28 29 |
# File 'lib/sass/script/interpolation.rb', line 27
def inspect
"(interpolation #{@before.inspect} #{@mid.inspect} #{@after.inspect})"
end
|
#to_sass(opts = {})
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/sass/script/interpolation.rb', line 32
def to_sass(opts = {})
res = ""
res << @before.to_sass(opts) if @before
res << ' ' if @before && @whitespace_before
res << '#{' unless @originally_text
res << @mid.to_sass(opts)
res << '}' unless @originally_text
res << ' ' if @after && @whitespace_after
res << @after.to_sass(opts) if @after
res
end
|