Class: Hokusai::Event

Inherits:
Object
  • Object
show all
Defined in:
ui/src/hokusai/event.rb

Direct Known Subclasses

KeyboardEvent, MouseEvent

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bubblesObject (readonly)

Returns the value of attribute bubbles.



5
6
7
# File 'ui/src/hokusai/event.rb', line 5

def bubbles
  @bubbles
end

#capturesObject (readonly)

Returns the value of attribute captures.



5
6
7
# File 'ui/src/hokusai/event.rb', line 5

def captures
  @captures
end

#stoppedObject

Returns the value of attribute stopped.



6
7
8
# File 'ui/src/hokusai/event.rb', line 6

def stopped
  @stopped
end

Class Method Details

.name(name) ⇒ Object



8
9
10
# File 'ui/src/hokusai/event.rb', line 8

def self.name(name)
  @name = name
end

Instance Method Details

#bubbleObject



43
44
45
46
47
48
49
# File 'ui/src/hokusai/event.rb', line 43

def bubble
  while block = captures.pop
    block.emit(name, self)

    break if stopped
  end
end

#matches(block) ⇒ Object



36
37
38
39
40
41
# File 'ui/src/hokusai/event.rb', line 36

def matches(block)
  return false if block.node.portal.nil?

  val = block.node.portal.ast.event(name)
  !!val
end

#nameObject



12
13
14
# File 'ui/src/hokusai/event.rb', line 12

def name
  self.class.instance_variable_get("@name")
end

#stopObject



20
21
22
# File 'ui/src/hokusai/event.rb', line 20

def stop
  self.stopped = true
end

#to_jsonObject

Raises:



32
33
34
# File 'ui/src/hokusai/event.rb', line 32

def to_json
  raise Hokusai::Error.new("#{self.class} must implement to_json")
end