class Lingo::Call

Constants

CHANNELS

Public Class Methods

new(args = []) click to toggle source
Calls superclass method
# File lib/lingo/call.rb, line 32
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 36
def call
  invite

  if block_given?
    begin
      yield self
    ensure
      reset
    end
  else
    self
  end
end
talk(input, raw = false) { |i| ... } click to toggle source
# File lib/lingo/call.rb, line 50
def talk(input, raw = false)
  config.stdin.reopen(
    input.respond_to?(:read) ? input.read : input)

  start

  res = CHANNELS.flat_map { |key|
    io = config.send(key)
    io.rewind

    lines = io.readlines

    io.truncate(0)
    io.rewind

    lines
  }

  return res.join if raw

  res.each { |i| i.chomp! }

  block_given? ? res.map! { |i| yield i } : begin
    res.sort! unless ENV['LINGO_NO_SORT']
    res.uniq!
    res
  end
end