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



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

#configObject (readonly)

Returns the value of attribute config.



5
6
7
# File 'lib/rshade/event_observer.rb', line 5

def config
  @config
end

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