class Lingo::Call

Public Class Methods

new(args = []) click to toggle source
# File lib/lingo/call.rb, line 30
def initialize(args = [])
  super(args, StringIO.new, StringIO.new, StringIO.new)
end

Public Instance Methods

call() { |self| ... } click to toggle source
# File lib/lingo/call.rb, line 34
def call
  invite

  if block_given?
    begin
      yield self
    ensure
      reset
    end
  else
    self
  end
end
talk(str) click to toggle source
# File lib/lingo/call.rb, line 48
def talk(str)
  config.stdin.reopen(str)

  start

  %w[stdout stderr].flat_map { |key|
    io = config.send(key).tap(&:rewind)
    io.readlines.each(&:chomp!).tap {
      io.truncate(0)
      io.rewind
    }
  }.tap { |res|
    if block_given?
      res.map!(&Proc.new)
    else
      res.sort!
      res.uniq!
    end
  }
end