Class: OCR::Ocr

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

Direct Known Subclasses

Dummy, Free_ocr, Onlineocr

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

#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)


42
43
44
# File 'lib/ocr/ocr.rb', line 42

def error?
  @error != false
end

#initObject



17
18
19
20
21
22
23
24
25
26
27
# 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
end

#login(username, password, extra_login_data = false) ⇒ Object



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

def  username, password,  = false
  @username = username
  @password = password
  @extra_login_data = 
end

#outputfile?Boolean

Returns:

  • (Boolean)


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

def outputfile?
  outputfile != false
end

#proxy(p_addr, p_port = nil, p_user = nil, p_pass = nil) ⇒ Object



35
36
37
38
39
40
# File 'lib/ocr/ocr.rb', line 35

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



50
51
52
53
54
55
56
# File 'lib/ocr/ocr.rb', line 50

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)
  ocr_recognize
end