Class: Event

Inherits:
Object
  • Object
show all
Defined in:
lib/a-commons.rb

Overview

------------------------------------------

Event

------------------------------------------

Direct Known Subclasses

ArcadiaEvent

Defined Under Namespace

Classes: Result

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_sender, _args = nil) ⇒ Event

Returns a new instance of Event.



538
539
540
541
542
543
544
545
546
547
548
549
550
# File 'lib/a-commons.rb', line 538

def initialize(_sender, _args=nil)
  @breaked = false
  @sender = _sender
  @channel = '0'
  if _args
    _args.each do |key, value|
      #self.send(key, value)
      self.send(key.to_s+'=', value) if self.respond_to?(key.to_s)
    end
  end
  @time = Time.new
  @results = Array.new
end

Instance Attribute Details

#channelObject (readonly)

Returns the value of attribute channel.



535
536
537
# File 'lib/a-commons.rb', line 535

def channel
  @channel
end

#parentObject

Returns the value of attribute parent.



534
535
536
# File 'lib/a-commons.rb', line 534

def parent
  @parent
end

#resultsObject (readonly)

Returns the value of attribute results.



537
538
539
# File 'lib/a-commons.rb', line 537

def results
  @results
end

#senderObject (readonly)

Returns the value of attribute sender.



533
534
535
# File 'lib/a-commons.rb', line 533

def sender
  @sender
end

#timeObject (readonly)

Returns the value of attribute time.



536
537
538
# File 'lib/a-commons.rb', line 536

def time
  @time
end

Instance Method Details

#add_finalize_callback(_proc) ⇒ Object



552
553
554
# File 'lib/a-commons.rb', line 552

def add_finalize_callback(_proc)
  ObjectSpace.define_finalizer(self, _proc)
end

#add_result(_sender, _args = nil) ⇒ Object



556
557
558
559
560
561
562
563
564
# File 'lib/a-commons.rb', line 556

def add_result(_sender, _args=nil)
  if self.class::Result
    res = self.class::Result.new(_sender, _args)
  else
    res = Result.new(_sender, _args)
  end
  @results << res
  res
end

#breakObject



570
571
572
# File 'lib/a-commons.rb', line 570

def break
  @breaked = true
end

#is_breaked?Boolean

Returns:

  • (Boolean)


566
567
568
# File 'lib/a-commons.rb', line 566

def is_breaked?
  @breaked
end