Class: Less::Node::Variable

Inherits:
Property show all
Defined in:
lib/less/engine/nodes/property.rb

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?, #eval?, #nearest, #parent=

Methods included from Entity

#path, #root

Constructor Details

#initialize(key, value = nil, parent = nil) ⇒ Variable

Returns a new instance of Variable.



74
75
76
77
# File 'lib/less/engine/nodes/property.rb', line 74

def initialize key, value = nil, parent = nil   
  @declaration = value ? true : false 
  super key.delete('@'), value, parent
end

Instance Attribute Details

#declarationObject (readonly)

Returns the value of attribute declaration.



72
73
74
# File 'lib/less/engine/nodes/property.rb', line 72

def declaration
  @declaration
end

Instance Method Details

#evaluateObject



87
88
89
90
91
92
93
# File 'lib/less/engine/nodes/property.rb', line 87

def evaluate
  if declaration
    @eval ||= value.evaluate
  else          
    @eval ||= self.parent.nearest(to_s).evaluate
  end
end

#inspectObject



79
80
81
# File 'lib/less/engine/nodes/property.rb', line 79

def inspect
  "@#{super}"
end

#to_cssObject



99
100
101
102
103
104
105
106
# File 'lib/less/engine/nodes/property.rb', line 99

def to_css
  evaluate
  if @eval.respond_to? :to_css
    @eval.to_css
  else
    @eval.map {|i| i.to_css }.join ', '
  end
end

#to_rubyObject



95
96
97
# File 'lib/less/engine/nodes/property.rb', line 95

def to_ruby
  evaluate.to_ruby
end

#to_sObject



83
84
85
# File 'lib/less/engine/nodes/property.rb', line 83

def to_s
  "@#{super}"
end