Class: Event::Events
- Includes:
- FromHash
- Defined in:
- lib/ascension/events.rb
Instance Attribute Summary collapse
-
#side ⇒ Object
Returns the value of attribute side.
Instance Method Summary collapse
- #<<(event) ⇒ Object
- #[](i) ⇒ Object
- #cond?(&b) ⇒ Boolean
- #first?(event) ⇒ Boolean
- #propagate(event) ⇒ Object
Instance Attribute Details
#side ⇒ Object
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
26 27 28 |
# File 'lib/ascension/events.rb', line 26 def cond?(&b) events.any?(&b) end |
#first?(event) ⇒ 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 |