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.



307
308
309
310
311
312
313
314
315
316
317
318
319
# File 'lib/a-commons.rb', line 307

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+'=', value)
    end
  end
  @time = Time.new
  @results = Array.new
end

Instance Attribute Details

#channelObject (readonly)

Returns the value of attribute channel.



304
305
306
# File 'lib/a-commons.rb', line 304

def channel
  @channel
end

#parentObject

Returns the value of attribute parent.



303
304
305
# File 'lib/a-commons.rb', line 303

def parent
  @parent
end

#resultsObject (readonly)

Returns the value of attribute results.



306
307
308
# File 'lib/a-commons.rb', line 306

def results
  @results
end

#senderObject (readonly)

Returns the value of attribute sender.



302
303
304
# File 'lib/a-commons.rb', line 302

def sender
  @sender
end

#timeObject (readonly)

Returns the value of attribute time.



305
306
307
# File 'lib/a-commons.rb', line 305

def time
  @time
end

Instance Method Details

#add_finalize_callback(_proc) ⇒ Object



321
322
323
# File 'lib/a-commons.rb', line 321

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

#add_result(_sender, _args = nil) ⇒ Object



325
326
327
328
329
330
331
332
333
# File 'lib/a-commons.rb', line 325

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



339
340
341
# File 'lib/a-commons.rb', line 339

def break
  @breaked = true
end

#is_breaked?Boolean

Returns:

  • (Boolean)


335
336
337
# File 'lib/a-commons.rb', line 335

def is_breaked?
  @breaked
end