Module: Pocketsphinx::API::CallHelpers

Included in:
Decoder, Microphone
Defined in:
lib/pocketsphinx/api/call_helpers.rb

Instance Method Summary collapse

Instance Method Details

#api_call(method, *args) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/pocketsphinx/api/call_helpers.rb', line 6

def api_call(method, *args)
  calling_method = caller[0][/`.*'/][1..-2]
  ps_api.send(method, *args).tap do |result|
    if result < 0
      raise Error, "#{self.class.to_s.split('::').last}##{calling_method} failed with error code #{result}"
    end
  end
end