Method: Less::Node::Element#nearest

Defined in:
lib/less/engine/nodes/element.rb

#nearest(ident) ⇒ Object

Find the nearest variable in the hierarchy or raise a NameError



112
113
114
115
116
117
118
119
# File 'lib/less/engine/nodes/element.rb', line 112

def nearest ident
  ary = ident =~ /^[.#]/ ? :elements : :variables
  path.map do |node|
    node.send(ary).find {|i| i.to_s == ident }
  end.compact.first.tap do |result|
    raise VariableNameError, ident unless result
  end
end