Class: OCR::Weocr

Inherits:
Ocr show all
Defined in:
lib/ocrs/weocr.rb

Instance Attribute Summary collapse

Attributes inherited from Ocr

#debug, #error, #extra_login_data, #file, #format, #language, #outputfile, #password, #proxy_addr, #proxy_pass, #proxy_port, #proxy_user, #rescue_exceptions, #text, #username

Attributes inherited from Factory

#args

Instance Method Summary collapse

Methods inherited from Ocr

#error?, #initialize, #login, #outputfile?, #proxy, #recognize, #rescue_exceptions?

Methods inherited from Factory

create, #initialize

Constructor Details

This class inherits a constructor from OCR::Ocr

Instance Attribute Details

#outputencodingObject

Returns the value of attribute outputencoding.



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

def outputencoding
  @outputencoding
end

#server_cgiObject

Returns the value of attribute server_cgi.



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

def server_cgi
  @server_cgi
end

#serversObject

Returns the value of attribute servers.



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

def servers
  @servers
end

#servers_infoObject

Returns the value of attribute servers_info.



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

def servers_info
  @servers_info
end

Instance Method Details

#ocr_serversObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ocrs/weocr.rb', line 10

def ocr_servers
  @servers = []
  @servers_info = {}
  # Get OCR servers
  url = 'http://weocr.ocrgrid.org/cgi-bin/weocr/search.cgi?lang=&fmt=xml'
  xml_data = Net::HTTP.get(URI.parse(url))
  doc = REXML::Document.new(xml_data)
  doc.elements.each('weocrlist/server/url') do |ele|
    @servers << ele.text
  end

  return unless @servers.count > 0

  xml_data = Net::HTTP.get(URI.parse("#{@servers[0]}srvspec.xml"))
  doc = REXML::Document.new(xml_data)
  doc.elements.each('ocrserver/svinfo/cgi') do |ele|
    @server_cgi = ele.text
  end
end