Class: Abbyy::Client

Inherits:
Object
  • Object
show all
Includes:
Task, XML
Defined in:
lib/abbyy/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from XML

#parse_error, #parse_task

Constructor Details

#initialize(application_id = Abbyy.application_id, password = Abbyy.password) ⇒ Client

Returns a new instance of Client.



12
13
14
15
16
17
# File 'lib/abbyy/client.rb', line 12

def initialize(application_id = Abbyy.application_id, password = Abbyy.password)
  @appliction_id = application_id
  @password = password
  @url = "http://#{CGI.escape(@appliction_id)}:#{CGI.escape(@password)}@cloud.ocrsdk.com"
  @task = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object



35
36
37
38
39
# File 'lib/abbyy/client.rb', line 35

def method_missing(meth, *args, &block)
  api = API.new self
  self.resource = api.execute meth, *args, &block
  current_task
end

Instance Attribute Details

#taskObject (readonly) Also known as: current_task

Returns the value of attribute task.



10
11
12
# File 'lib/abbyy/client.rb', line 10

def task
  @task
end

#urlObject (readonly)

Returns the value of attribute url.



10
11
12
# File 'lib/abbyy/client.rb', line 10

def url
  @url
end

Instance Method Details

#get(url = task[:resultUrl]) ⇒ String

Retrieve the result of processing task

Parameters:

  • the (String)

    url of the task result

Returns:

  • (String)

    the xml representation



25
26
27
# File 'lib/abbyy/client.rb', line 25

def get(url = task[:resultUrl])
  RestClient.get(url)
end

#list_tasksArray

Returns:

  • (Array)

    the list of tasks created



31
32
33
# File 'lib/abbyy/client.rb', line 31

def list_tasks
  parse_task get("#{url}/listTasks")
end