module CExpect::ModuleMethods

Module methods for CExpect

Public Instance Methods

cexpect_wrap(array, &block) click to toggle source

Assume first element benefits from using CExpect

This generalization is a bit iffy; it works for class methods that returns and yields an IO reader first, followed by any other parameters. But hey, if we need to wrap things that behave differently, we can just give this one (and its shared examples in the specs) a more specific name and implement another.

# File lib/cexpect/module_methods.rb, line 19
def cexpect_wrap(array, &block)
  array[0] = CExpect::Reader.new(array[0])
  if block_given?
    block.call(*array)
  else
    array
  end
end
pipe(*args, &block) click to toggle source
# File lib/cexpect/module_methods.rb, line 28
def pipe(*args, &block)
  cexpect_wrap(IO.pipe(*args), &block)
end
spawn(*args, &block) click to toggle source
# File lib/cexpect/module_methods.rb, line 32
def spawn(*args, &block)
  cexpect_wrap(PTY.spawn(*args), &block)
end