Class: Event::Events

Inherits:
Object show all
Includes:
FromHash
Defined in:
lib/ascension/events.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#sideObject

Returns the value of attribute side.



10
11
12
# File 'lib/ascension/events.rb', line 10

def side
  @side
end

Instance Method Details

#<<(event) ⇒ Object



12
13
14
15
16
# File 'lib/ascension/events.rb', line 12

def <<(event)
  event.first = true if first?(event)
  self.events << event
  propagate(event)
end

#[](i) ⇒ Object



23
24
25
# File 'lib/ascension/events.rb', line 23

def [](i)
  events[i]
end

#cond?(&b) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/ascension/events.rb', line 26

def cond?(&b)
  events.any?(&b)
end

#first?(event) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/ascension/events.rb', line 20

def first?(event)
  events.select { |x| x.key == event.key && x.class == event.class }.empty?#.tap { |x| puts "first? #{x}" }
end

#propagate(event) ⇒ Object



17
18
19
# File 'lib/ascension/events.rb', line 17

def propagate(event)
  side.constructs.each { |c| c.apply_triggers(event,side) } if side
end