Module: Betfair::API::ErrorPresenter

Defined in:
lib/betfair/api.rb

Overview

Mix this into a Hash to give it basic error reporting and a nice path-based data extractor.

Instance Method Summary collapse

Instance Method Details

#format_errorObject



380
381
382
# File 'lib/betfair/api.rb', line 380

def format_error
  "#{self[:error_code]} - #{self[:header][:error_code]}"
end

#maybe_result(*path) ⇒ Object



385
386
387
388
389
390
391
# File 'lib/betfair/api.rb', line 385

def maybe_result( *path )
  if success?
    path.inject(self){|m,r| m[r]}.extend( Success )
  else
    format_error().extend( Failure )
  end
end

#success?Boolean

Returns:

  • (Boolean)


375
376
377
# File 'lib/betfair/api.rb', line 375

def success?
  self[:error_code] == "OK"
end