Class: Less::Node::Variable
Instance Attribute Summary collapse
Attributes inherited from Property
#value
Attributes included from Entity
#parent
Instance Method Summary
collapse
Methods inherited from Property
#<<, #==, #copy, #empty?, #eql?, #nearest, #parent=
Methods included from Entity
#path, #root
Constructor Details
#initialize(key, value = nil, parent = nil) ⇒ Variable
Returns a new instance of Variable.
93
94
95
96
|
# File 'lib/less/engine/nodes/property.rb', line 93
def initialize key, value = nil, parent = nil
@declaration = value ? true : false
super key.delete('@'), value, parent
end
|
Instance Attribute Details
#declaration ⇒ Object
Returns the value of attribute declaration.
91
92
93
|
# File 'lib/less/engine/nodes/property.rb', line 91
def declaration
@declaration
end
|
Instance Method Details
#evaluate(env = nil) ⇒ Object
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
# File 'lib/less/engine/nodes/property.rb', line 106
def evaluate env = nil
if declaration
value.evaluate else
begin
var = (env || self.parent).nearest(to_s) rescue VariableNameError
var = self.parent.nearest(to_s)
end
var.evaluate
end
end
|
#inspect ⇒ Object
98
99
100
|
# File 'lib/less/engine/nodes/property.rb', line 98
def inspect
"@#{super}"
end
|
#to_css(env = nil) ⇒ Object
125
126
127
128
129
130
131
132
|
# File 'lib/less/engine/nodes/property.rb', line 125
def to_css env = nil
val = evaluate env
if val.respond_to? :to_css
env ? val.to_css(env) : val.to_css
else
val.map {|i| env ? i.to_css(env) : i.to_css }.join ', '
end
end
|
#to_ruby ⇒ Object
121
122
123
|
# File 'lib/less/engine/nodes/property.rb', line 121
def to_ruby
evaluate.to_ruby
end
|
#to_s ⇒ Object
102
103
104
|
# File 'lib/less/engine/nodes/property.rb', line 102
def to_s
"@#{super}"
end
|