Class: CSSPool::Visitors::Visitor

Inherits:
Object
  • Object
show all
Defined in:
lib/csspool/visitors/visitor.rb

Direct Known Subclasses

Children, Comparable, Iterator, ToCSS

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.visitor_for(*klasses, &block) ⇒ Object



4
5
6
7
8
9
# File 'lib/csspool/visitors/visitor.rb', line 4

def self.visitor_for *klasses, &block
  klasses.each do |klass|
    method_name = klass.name.split('::').join('_')
    define_method(:"visit_#{method_name}", block)
  end
end

Instance Method Details

#accept(target) ⇒ Object



11
12
13
14
# File 'lib/csspool/visitors/visitor.rb', line 11

def accept target
  method_name = target.class.name.split('::').join('_')
  send(:"visit_#{method_name}", target)
end