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
Returns a new instance of EventObserver.
7 8 9 10 11 12 13 14 |
# File 'lib/rshade/event_observer.rb', line 7 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.
3 4 5 |
# File 'lib/rshade/event_observer.rb', line 3 def config @config end |
#event_processor ⇒ Object (readonly)
Returns the value of attribute event_processor.
3 4 5 |
# File 'lib/rshade/event_observer.rb', line 3 def event_processor @event_processor end |
Instance Method Details
#call(event, type) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/rshade/event_observer.rb', line 18 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 |