Class: Event

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

Overview

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

Event

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

Direct Known Subclasses

ArcadiaEvent

Defined Under Namespace

Classes: Result

Constant Summary collapse

FLAG_ERROR =
'E'
FLAG_DEFAULT =
'0'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_sender, _args = nil) ⇒ Event

Returns a new instance of Event.



653
654
655
656
657
658
659
660
661
662
663
664
665
666
# File 'lib/a-commons.rb', line 653

def initialize(_sender, _args=nil)
  @breaked = false
  @sender = _sender
  @channel = '0'
  @flag= FLAG_DEFAULT
  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.



647
648
649
# File 'lib/a-commons.rb', line 647

def channel
  @channel
end

#flagObject

is used to give a state to event



649
650
651
# File 'lib/a-commons.rb', line 649

def flag
  @flag
end

#parentObject

Returns the value of attribute parent.



646
647
648
# File 'lib/a-commons.rb', line 646

def parent
  @parent
end

#resultsObject (readonly)

Returns the value of attribute results.



650
651
652
# File 'lib/a-commons.rb', line 650

def results
  @results
end

#senderObject (readonly)

Returns the value of attribute sender.



645
646
647
# File 'lib/a-commons.rb', line 645

def sender
  @sender
end

#timeObject (readonly)

Returns the value of attribute time.



648
649
650
# File 'lib/a-commons.rb', line 648

def time
  @time
end

Instance Method Details

#add_finalize_callback(_proc) ⇒ Object



668
669
670
# File 'lib/a-commons.rb', line 668

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

#add_result(_sender, _args = nil) ⇒ Object



672
673
674
675
676
677
678
679
680
# File 'lib/a-commons.rb', line 672

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



686
687
688
# File 'lib/a-commons.rb', line 686

def break
  @breaked = true
end

#is_breaked?Boolean

Returns:

  • (Boolean)


682
683
684
# File 'lib/a-commons.rb', line 682

def is_breaked?
  @breaked
end