Class: OCR::Ocr
Instance Attribute Summary collapse
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#extra_login_data ⇒ Object
Returns the value of attribute extra_login_data.
-
#file ⇒ Object
Returns the value of attribute file.
-
#format ⇒ Object
Returns the value of attribute format.
-
#language ⇒ Object
Returns the value of attribute language.
-
#outputfile ⇒ Object
Returns the value of attribute outputfile.
-
#password ⇒ Object
Returns the value of attribute password.
-
#proxy_addr ⇒ Object
Returns the value of attribute proxy_addr.
-
#proxy_pass ⇒ Object
Returns the value of attribute proxy_pass.
-
#proxy_port ⇒ Object
Returns the value of attribute proxy_port.
-
#proxy_user ⇒ Object
Returns the value of attribute proxy_user.
-
#rescue_exceptions ⇒ Object
Returns the value of attribute rescue_exceptions.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#username ⇒ Object
Returns the value of attribute username.
Attributes inherited from Factory
Instance Method Summary collapse
- #error? ⇒ Boolean
- #init ⇒ Object
-
#initialize(*args) ⇒ Ocr
constructor
A new instance of Ocr.
- #login(username, password, extra_login_data = false) ⇒ Object
- #outputfile? ⇒ Boolean
- #proxy(p_addr, p_port = nil, p_user = nil, p_pass = nil) ⇒ Object
- #recognize ⇒ Object
- #rescue_exceptions? ⇒ Boolean
Methods inherited from Factory
Constructor Details
#initialize(*args) ⇒ Ocr
Returns a new instance of Ocr.
13 14 15 |
# File 'lib/ocr/ocr.rb', line 13 def initialize(*args) init end |
Instance Attribute Details
#debug ⇒ Object
Returns the value of attribute debug.
11 12 13 |
# File 'lib/ocr/ocr.rb', line 11 def debug @debug end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
7 8 9 |
# File 'lib/ocr/ocr.rb', line 7 def error @error end |
#extra_login_data ⇒ Object
Returns the value of attribute extra_login_data.
8 9 10 |
# File 'lib/ocr/ocr.rb', line 8 def extra_login_data @extra_login_data end |
#file ⇒ Object
Returns the value of attribute file.
10 11 12 |
# File 'lib/ocr/ocr.rb', line 10 def file @file end |
#format ⇒ Object
Returns the value of attribute format.
10 11 12 |
# File 'lib/ocr/ocr.rb', line 10 def format @format end |
#language ⇒ Object
Returns the value of attribute language.
10 11 12 |
# File 'lib/ocr/ocr.rb', line 10 def language @language end |
#outputfile ⇒ Object
Returns the value of attribute outputfile.
10 11 12 |
# File 'lib/ocr/ocr.rb', line 10 def outputfile @outputfile end |
#password ⇒ Object
Returns the value of attribute password.
8 9 10 |
# File 'lib/ocr/ocr.rb', line 8 def password @password end |
#proxy_addr ⇒ Object
Returns the value of attribute proxy_addr.
9 10 11 |
# File 'lib/ocr/ocr.rb', line 9 def proxy_addr @proxy_addr end |
#proxy_pass ⇒ Object
Returns the value of attribute proxy_pass.
9 10 11 |
# File 'lib/ocr/ocr.rb', line 9 def proxy_pass @proxy_pass end |
#proxy_port ⇒ Object
Returns the value of attribute proxy_port.
9 10 11 |
# File 'lib/ocr/ocr.rb', line 9 def proxy_port @proxy_port end |
#proxy_user ⇒ Object
Returns the value of attribute proxy_user.
9 10 11 |
# File 'lib/ocr/ocr.rb', line 9 def proxy_user @proxy_user end |
#rescue_exceptions ⇒ Object
Returns the value of attribute rescue_exceptions.
11 12 13 |
# File 'lib/ocr/ocr.rb', line 11 def rescue_exceptions @rescue_exceptions end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
7 8 9 |
# File 'lib/ocr/ocr.rb', line 7 def text @text end |
#username ⇒ Object
Returns the value of attribute username.
8 9 10 |
# File 'lib/ocr/ocr.rb', line 8 def username @username end |
Instance Method Details
#error? ⇒ Boolean
47 48 49 |
# File 'lib/ocr/ocr.rb', line 47 def error? @error != false end |
#init ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ocr/ocr.rb', line 17 def init clear_error clear_text login false, false proxy false file= false lang= false format= false outputfile= false debug= false rescue_exceptions= true end |
#login(username, password, extra_login_data = false) ⇒ Object
34 35 36 37 38 |
# File 'lib/ocr/ocr.rb', line 34 def login username, password, extra_login_data = false @username = username @password = password @extra_login_data = extra_login_data end |
#outputfile? ⇒ Boolean
51 52 53 |
# File 'lib/ocr/ocr.rb', line 51 def outputfile? outputfile != false end |
#proxy(p_addr, p_port = nil, p_user = nil, p_pass = nil) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/ocr/ocr.rb', line 40 def proxy p_addr, p_port = nil, p_user = nil, p_pass = nil @proxy_addr = p_addr @proxy_port = p_port @proxy_user = p_user @proxy_pass = p_pass end |
#recognize ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/ocr/ocr.rb', line 55 def recognize clear_error clear_text return false && set_error("No file") if @file.nil? return false && set_error("File not exists '#{@file}'") unless File.exist?(@file) begin ocr_recognize rescue Exception => msg set_error msg raise unless rescue_exceptions? end end |
#rescue_exceptions? ⇒ Boolean
30 31 32 |
# File 'lib/ocr/ocr.rb', line 30 def rescue_exceptions? @rescue_exceptions != false end |