Class: EventMachine::POSIX::Spawn::Child::ReadableStream::Listener

Inherits:
Object
  • Object
show all
Defined in:
lib/em/posix/spawn/child.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, &block) ⇒ Listener

Returns a new instance of Listener.



364
365
366
367
368
# File 'lib/em/posix/spawn/child.rb', line 364

def initialize(name, &block)
  @name = name
  @block = block
  @offset = 0
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



362
363
364
# File 'lib/em/posix/spawn/child.rb', line 362

def name
  @name
end

Instance Method Details

#call(buffer) ⇒ Object

Sends the part of the buffer that has not yet been sent.



371
372
373
374
375
376
# File 'lib/em/posix/spawn/child.rb', line 371

def call(buffer)
  return if @block.nil?

  to_call = @block
  to_call.call(self, slice_from_buffer(buffer))
end

#close(buffer = "") ⇒ Object

Sends the part of the buffer that has not yet been sent, after closing the listener. After this, the listener will not receive any more calls.



381
382
383
384
385
386
# File 'lib/em/posix/spawn/child.rb', line 381

def close(buffer = "")
  return if @block.nil?

  to_call, @block = @block, nil
  to_call.call(self, slice_from_buffer(buffer))
end

#closed?Boolean

Returns:



388
389
390
# File 'lib/em/posix/spawn/child.rb', line 388

def closed?
  @block.nil?
end