Class: Loompa::Child
- Inherits:
-
Object
- Object
- Loompa::Child
- Defined in:
- lib/loompa.rb
Instance Attribute Summary collapse
-
#from ⇒ Object
status is one of :idle, :connect, :close, :exit.
-
#pid ⇒ Object
status is one of :idle, :connect, :close, :exit.
-
#to ⇒ Object
status is one of :idle, :connect, :close, :exit.
Instance Method Summary collapse
- #active? ⇒ Boolean
- #close ⇒ Object
- #event(s) ⇒ Object
- #exit ⇒ Object
- #idle? ⇒ Boolean
-
#initialize(pid, from, to) ⇒ Child
constructor
A new instance of Child.
Constructor Details
#initialize(pid, from, to) ⇒ Child
Returns a new instance of Child.
66 67 68 69 |
# File 'lib/loompa.rb', line 66 def initialize(pid, from, to) @pid, @from, @to = pid, from, to @status = :idle end |
Instance Attribute Details
#from ⇒ Object
status is one of :idle, :connect, :close, :exit
72 73 74 |
# File 'lib/loompa.rb', line 72 def from @from end |
#pid ⇒ Object
status is one of :idle, :connect, :close, :exit
72 73 74 |
# File 'lib/loompa.rb', line 72 def pid @pid end |
#to ⇒ Object
status is one of :idle, :connect, :close, :exit
72 73 74 |
# File 'lib/loompa.rb', line 72 def to @to end |
Instance Method Details
#active? ⇒ Boolean
103 104 105 |
# File 'lib/loompa.rb', line 103 def active?() @status == :idle or @status == :connect end |
#close ⇒ Object
88 89 90 91 |
# File 'lib/loompa.rb', line 88 def close() @to.close unless @to.closed? @status = :close end |
#event(s) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/loompa.rb', line 74 def event(s) if s == nil then #Loompa.logger.debug "p: child #{pid} terminated" self.exit else case s.chomp when "connect" then @status = :connect when "disconnect" then @status = :idle else $stderr.puts "unknown status: #{s}" end end end |
#exit ⇒ Object
93 94 95 96 97 |
# File 'lib/loompa.rb', line 93 def exit() @from.close unless @from.closed? @to.close unless @to.closed? @status = :exit end |
#idle? ⇒ Boolean
99 100 101 |
# File 'lib/loompa.rb', line 99 def idle?() @status == :idle end |