class Less::Node::Property
Attributes
value[RW]
Public Class Methods
new(key, value = nil, parent = nil)
click to toggle source
Calls superclass method
Less::Node::Entity.new
# File lib/less/engine/nodes/property.rb, line 8 def initialize key, value = nil, parent = nil super key, parent value = if value.is_a? Array value.each {|v| v.parent = self if v.respond_to? :parent }. map {|v| v.is_a?(Expression) ? v : Expression.new(v, self) } elsif value.nil? [] else value end @value = value.is_a?(Expression) ? value : Expression.new(value, self) @value.parent = self @value.delimiter = ',' # puts "new property #{to_s}: #{value} => #{@value}, contains: #{@value[0].class}" # puts end
Public Instance Methods
<<(token)
click to toggle source
# File lib/less/engine/nodes/property.rb, line 34 def << token token = Node::Anonymous.new(*token) unless token.is_a? Entity or token.respond_to? :to_ruby token.parent = self if token.respond_to? :parent @value << token end
==(other)
click to toggle source
# File lib/less/engine/nodes/property.rb, line 46 def == other self.to_s == other.to_s end
copy()
click to toggle source
# File lib/less/engine/nodes/property.rb, line 30 def copy clone.tap {|c| c.value = value.copy } end
empty?()
click to toggle source
# File lib/less/engine/nodes/property.rb, line 40 def empty?; !@value || @value.empty? end
eql?(other)
click to toggle source
# File lib/less/engine/nodes/property.rb, line 50 def eql? other self == other and value.eql? other.value end
evaluate(env = nil)
click to toggle source
# File lib/less/engine/nodes/property.rb, line 62 def evaluate env = nil # puts "evaluating property `#{to_s}`: #{value.inspect}" if value.is_a?(Expression) #Value # puts "value is a Value" value.map {|e| e.evaluate(env) } #6 else # puts "value is a #{value.class}" [value.evaluate(env)] end end
inspect()
click to toggle source
# File lib/less/engine/nodes/property.rb, line 42 def inspect self + (empty?? "" : ": `#{value.map {|i| i.to_s } * ' | '}`") end
nearest(node)
click to toggle source
# File lib/less/engine/nodes/property.rb, line 58 def nearest node parent.nearest node end
parent=(obj)
click to toggle source
# File lib/less/engine/nodes/property.rb, line 25 def parent= obj @parent = obj value.parent = self end
to_css(env = nil)
click to toggle source
# File lib/less/engine/nodes/property.rb, line 75 def to_css env = nil # puts "property.to_css `#{to_s}` env:#{env ? env.variables : "nil"}" val = evaluate(env) "#{self}: #{if val.respond_to? :to_css val.to_css else # p val # puts "#{val.class} #{val.first.class}" val.map {|i| i.to_css }.join(", ") end};" end
to_s()
click to toggle source
Calls superclass method
Less::Node::Entity#to_s
# File lib/less/engine/nodes/property.rb, line 54 def to_s super end