Class: Less::Node::Property
- Includes:
- Entity
- Defined in:
- lib/less/engine/nodes/property.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#value ⇒ Object
Returns the value of attribute value.
Attributes included from Entity
Instance Method Summary collapse
- #<<(token) ⇒ Object
- #empty? ⇒ Boolean
- #eval? ⇒ Boolean
-
#evaluate ⇒ Object
TODO: @eval and @value should be merged.
-
#initialize(key, value = nil) ⇒ Property
constructor
A new instance of Property.
- #inspect ⇒ Object
- #to_css ⇒ Object
- #to_s ⇒ Object
Methods included from Entity
Constructor Details
#initialize(key, value = nil) ⇒ Property
Returns a new instance of Property.
8 9 10 11 12 13 |
# File 'lib/less/engine/nodes/property.rb', line 8 def initialize key, value = nil super key log "\n[new] #{self.class} `#{key}`\n" @value = Expression.new(value ? [value] : []) @eval = false # Store the first evaluation in here end |
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
6 7 8 |
# File 'lib/less/engine/nodes/property.rb', line 6 def value @value end |
Instance Method Details
#<<(token) ⇒ Object
15 16 17 18 19 |
# File 'lib/less/engine/nodes/property.rb', line 15 def << token log "[adding] to #{self.to_s}: '#{token.to_s}' <#{token.class}>\n" token = Node::Anonymous.new(*token) unless token.is_a? Entity or token.is_a? Operator @value << token end |
#empty? ⇒ Boolean
21 |
# File 'lib/less/engine/nodes/property.rb', line 21 def empty?; !@value || @value.empty? end |
#eval? ⇒ Boolean
22 |
# File 'lib/less/engine/nodes/property.rb', line 22 def eval?; @eval end |
#evaluate ⇒ Object
TODO: @eval and @value should be merged
33 34 35 |
# File 'lib/less/engine/nodes/property.rb', line 33 def evaluate @eval || @eval = value.evaluate end |
#inspect ⇒ Object
24 25 26 |
# File 'lib/less/engine/nodes/property.rb', line 24 def inspect self + (empty?? "" : ": `#{value.map {|i| i.to_s } * ' | '}`") end |
#to_css ⇒ Object
37 38 39 |
# File 'lib/less/engine/nodes/property.rb', line 37 def to_css "#{self}: #{evaluate.to_css};" end |
#to_s ⇒ Object
28 29 30 |
# File 'lib/less/engine/nodes/property.rb', line 28 def to_s super end |