Class: OCR::Ocr

Inherits:
Factory show all
Defined in:
lib/ocr/ocr.rb

Direct Known Subclasses

Dummy, Free_ocr, Onlineocr, Weocr

Instance Attribute Summary collapse

Attributes inherited from Factory

#args

Instance Method Summary collapse

Methods inherited from Factory

create

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

#debugObject

Returns the value of attribute debug.



11
12
13
# File 'lib/ocr/ocr.rb', line 11

def debug
  @debug
end

#errorObject (readonly)

Returns the value of attribute error.



7
8
9
# File 'lib/ocr/ocr.rb', line 7

def error
  @error
end

#extra_login_dataObject

Returns the value of attribute extra_login_data.



8
9
10
# File 'lib/ocr/ocr.rb', line 8

def 
  @extra_login_data
end

#fileObject

Returns the value of attribute file.



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

def file
  @file
end

#formatObject

Returns the value of attribute format.



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

def format
  @format
end

#languageObject

Returns the value of attribute language.



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

def language
  @language
end

#outputfileObject

Returns the value of attribute outputfile.



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

def outputfile
  @outputfile
end

#passwordObject

Returns the value of attribute password.



8
9
10
# File 'lib/ocr/ocr.rb', line 8

def password
  @password
end

#proxy_addrObject

Returns the value of attribute proxy_addr.



9
10
11
# File 'lib/ocr/ocr.rb', line 9

def proxy_addr
  @proxy_addr
end

#proxy_passObject

Returns the value of attribute proxy_pass.



9
10
11
# File 'lib/ocr/ocr.rb', line 9

def proxy_pass
  @proxy_pass
end

#proxy_portObject

Returns the value of attribute proxy_port.



9
10
11
# File 'lib/ocr/ocr.rb', line 9

def proxy_port
  @proxy_port
end

#proxy_userObject

Returns the value of attribute proxy_user.



9
10
11
# File 'lib/ocr/ocr.rb', line 9

def proxy_user
  @proxy_user
end

#rescue_exceptionsObject

Returns the value of attribute rescue_exceptions.



11
12
13
# File 'lib/ocr/ocr.rb', line 11

def rescue_exceptions
  @rescue_exceptions
end

#textObject (readonly)

Returns the value of attribute text.



7
8
9
# File 'lib/ocr/ocr.rb', line 7

def text
  @text
end

#usernameObject

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

Returns:

  • (Boolean)


47
48
49
# File 'lib/ocr/ocr.rb', line 47

def error?
  @error != false
end

#initObject



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
   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  username, password,  = false
  @username = username
  @password = password
  @extra_login_data = 
end

#outputfile?Boolean

Returns:

  • (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

#recognizeObject



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

Returns:

  • (Boolean)


30
31
32
# File 'lib/ocr/ocr.rb', line 30

def rescue_exceptions?
  @rescue_exceptions != false
end