Class: Less::Node::Function
- Defined in:
- lib/less/engine/nodes/function.rb
Overview
A CSS function, like rgb() or url()
it calls functions from the Functions module
Instance Attribute Summary
Attributes included from Entity
Instance Method Summary collapse
-
#evaluate ⇒ Object
Call the function.
-
#initialize(name, *args) ⇒ Function
constructor
A new instance of Function.
- #to_css ⇒ Object
Methods included from Functions
available, #hsl, #hsla, #rgb, #rgba
Methods included from Entity
Methods inherited from String
#blank?, #column_of, #indent, #line_of, #tabto, #treetop_camelize
Constructor Details
#initialize(name, *args) ⇒ Function
Returns a new instance of Function.
55 56 57 58 |
# File 'lib/less/engine/nodes/function.rb', line 55 def initialize name, *args @args = args.flatten super name end |
Instance Method Details
#evaluate ⇒ Object
Call the function
If the function isn’t found, we just print it out, this is the case for url(), for example,
70 71 72 73 74 75 76 |
# File 'lib/less/engine/nodes/function.rb', line 70 def evaluate if Functions.available.include? self.to_sym send to_sym, *@args else Node::Anonymous.new("#{to_sym}(#{@args.map(&:to_css) * ', '})") end end |
#to_css ⇒ Object
60 61 62 |
# File 'lib/less/engine/nodes/function.rb', line 60 def to_css self.evaluate.to_css end |