Class: Abbyy::Client
Constant Summary collapse
- API_ENDPOINT =
"cloud.ocrsdk.com"
Instance Attribute Summary collapse
-
#task ⇒ Object
(also: #current_task)
readonly
Returns the value of attribute task.
Instance Method Summary collapse
-
#get(url = task[:resultUrl]) ⇒ String
Retrieve the result of processing task.
-
#initialize(application_id = Abbyy.application_id, password = Abbyy.password) ⇒ Client
constructor
A new instance of Client.
- #list_tasks ⇒ Array
- #method_missing(meth, *args, &block) ⇒ Object
-
#url ⇒ String
The api url with credentials.
Methods included from Inflector
Methods included from XML
Constructor Details
#initialize(application_id = Abbyy.application_id, password = Abbyy.password) ⇒ Client
Returns a new instance of Client.
14 15 16 17 18 |
# File 'lib/abbyy/client.rb', line 14 def initialize(application_id = Abbyy.application_id, password = Abbyy.password) @appliction_id = application_id @password = password @task = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
46 47 48 49 50 |
# File 'lib/abbyy/client.rb', line 46 def method_missing(meth, *args, &block) api = API.new self self.resource = api.execute meth, *args, &block current_task end |
Instance Attribute Details
#task ⇒ Object (readonly) Also known as: current_task
Returns the value of attribute task.
12 13 14 |
# File 'lib/abbyy/client.rb', line 12 def task @task end |
Instance Method Details
#get(url = task[:resultUrl]) ⇒ String
Retrieve the result of processing task
36 37 38 |
# File 'lib/abbyy/client.rb', line 36 def get(url = task[:resultUrl]) RestClient.get(url) end |
#list_tasks ⇒ Array
42 43 44 |
# File 'lib/abbyy/client.rb', line 42 def list_tasks parse_task get("#{url}/listTasks") end |
#url ⇒ String
Returns the api url with credentials.
21 22 23 24 25 26 27 28 |
# File 'lib/abbyy/client.rb', line 21 def url @url ||= begin uri = URI::HTTP.build host: API_ENDPOINT uri.user = CGI.escape @appliction_id.to_s uri.password = CGI.escape @password.to_s if uri.user uri.to_s end end |