Class: Emb::MultiProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/emb/multi.rb

Defined Under Namespace

Classes: PairCollector

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ MultiProxy

Returns a new instance of MultiProxy.



5
6
7
8
# File 'lib/emb/multi.rb', line 5

def initialize(client)
  @client = client
  @pairs = []
end

Instance Method Details

#[](name) ⇒ Object



10
11
12
# File 'lib/emb/multi.rb', line 10

def [](name)
  PairCollector.new(@pairs, name.to_sym)
end

#runObject



14
15
16
17
18
19
20
# File 'lib/emb/multi.rb', line 14

def run
  args = @pairs.flat_map { |pair| [pair[:model].to_s, pair[:text]] }

  @client
    .send_command('EMB.MULTI', *args)
    .map { |entry| entry.unpack('e*') }
end