Class: RShade::EventObserver
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#event_processor ⇒ Object
readonly
Returns the value of attribute event_processor.
Instance Method Summary collapse
- #call(event, type) ⇒ Object
-
#initialize(config, event_processor) ⇒ EventObserver
constructor
A new instance of EventObserver.
Constructor Details
#initialize(config, event_processor) ⇒ EventObserver
9 10 11 12 13 14 15 16 |
# File 'lib/rshade/event_observer.rb', line 9 def initialize(config, event_processor) @event_processor = event_processor @config = config @level = 0 @hook = Hash.new(0) @hook[:enter] = 1 @hook[:leave] = -1 end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
5 6 7 |
# File 'lib/rshade/event_observer.rb', line 5 def config @config end |
#event_processor ⇒ Object (readonly)
Returns the value of attribute event_processor.
5 6 7 |
# File 'lib/rshade/event_observer.rb', line 5 def event_processor @event_processor end |
Instance Method Details
#call(event, type) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/rshade/event_observer.rb', line 20 def call(event, type) @level += @hook[type] return unless pass?(event) enter(event) if type == :enter leave(event) if type == :leave other(event) if type == :other end |