Class: LintFu::Visitor
- Inherits:
-
SexpProcessor
- Object
- SexpProcessor
- LintFu::Visitor
- Defined in:
- lib/lint_fu/visitor.rb
Instance Attribute Summary collapse
-
#observers ⇒ Object
readonly
Returns the value of attribute observers.
Instance Method Summary collapse
-
#initialize ⇒ Visitor
constructor
A new instance of Visitor.
- #process(sexp) ⇒ Object
Constructor Details
#initialize ⇒ Visitor
Returns a new instance of Visitor.
5 6 7 8 9 10 |
# File 'lib/lint_fu/visitor.rb', line 5 def initialize super self.require_empty = false self.auto_shift_type = false @observers = [] end |
Instance Attribute Details
#observers ⇒ Object (readonly)
Returns the value of attribute observers.
3 4 5 |
# File 'lib/lint_fu/visitor.rb', line 3 def observers @observers end |
Instance Method Details
#process(sexp) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/lint_fu/visitor.rb', line 12 def process(sexp) tag = sexp[0] begin_meth = "observe_#{tag}_begin".to_sym around_meth = "observe_#{tag}".to_sym end_meth = "observe_#{tag}_end".to_sym observers.each do |o| o.__send__(begin_meth, sexp) if o.respond_to?(begin_meth) end observers.each do |o| o.__send__(around_meth, sexp) if o.respond_to?(around_meth) end result = super(sexp) observers.each do |o| o.__send__(end_meth, sexp) if o.respond_to?(end_meth) end return result end |