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

#<<, #empty?, #eval?, #nearest

Methods included from Entity

#path, #root

Methods inherited from String

#blank?, #column_of, #indent, #line_of, #tabto, #treetop_camelize

Constructor Details

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

Returns a new instance of Variable.



57
58
59
60
# File 'lib/less/engine/nodes/property.rb', line 57

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.



55
56
57
# File 'lib/less/engine/nodes/property.rb', line 55

def declaration
  @declaration
end

Instance Method Details

#evaluateObject



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

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

#inspectObject



62
63
64
# File 'lib/less/engine/nodes/property.rb', line 62

def inspect
  "@#{super}"
end

#to_cssObject



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

def to_css
  evaluate.to_css
end

#to_rubyObject



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

def to_ruby
  evaluate.to_ruby
end

#to_sObject



66
67
68
# File 'lib/less/engine/nodes/property.rb', line 66

def to_s
  "@#{super}"
end