Class: Less::Node::Function

Inherits:
String show all
Includes:
Functions, Entity
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

#parent

Instance Method Summary collapse

Methods included from Entity

#inspect, #path, #root, #to_s

Methods included from Functions

#hsl, #hsla, #rgb, #rgba

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.



51
52
53
54
# File 'lib/less/engine/nodes/function.rb', line 51

def initialize name, *args
  @args = args.flatten
  super name
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args) ⇒ Object

If the function isn’t found, we just print it out, this is the case for url(), for example,



71
72
73
# File 'lib/less/engine/nodes/function.rb', line 71

def method_missing meth, *args
  Node::Anonymous.new("#{meth}(#{args.map(&:to_css) * ', '})")
end

Instance Method Details

#evaluateObject

Call the function



63
64
65
# File 'lib/less/engine/nodes/function.rb', line 63

def evaluate
  send self.to_sym, *@args
end

#to_cssObject



56
57
58
# File 'lib/less/engine/nodes/function.rb', line 56

def to_css
  self.evaluate.to_css
end