Class: RShade::EventObserver

Inherits:
Object
  • Object
show all
Defined in:
lib/rshade/event_observer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, event_processor) ⇒ EventObserver

Returns a new instance of EventObserver.

Parameters:



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

#configObject (readonly)

Returns the value of attribute config.



3
4
5
# File 'lib/rshade/event_observer.rb', line 3

def config
  @config
end

#event_processorObject (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

Parameters:



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