Class: OnlyofficeDocumentserverConversionHelper::XmlResponceParser

Inherits:
Object
  • Object
show all
Defined in:
lib/onlyoffice_documentserver_conversion_helper/xml_responce_parser.rb

Overview

Class for parse Xml responce

Instance Method Summary collapse

Constructor Details

#initialize(string_with_xml, file_format, result_in_zip: false) ⇒ XmlResponceParser

Returns a new instance of XmlResponceParser.



6
7
8
9
10
# File 'lib/onlyoffice_documentserver_conversion_helper/xml_responce_parser.rb', line 6

def initialize(string_with_xml, file_format, result_in_zip: false)
  @string_with_xml = string_with_xml
  @file_format = file_format
  @result_in_zip = result_in_zip
end

Instance Method Details

#file_formatString

Returns output file format.

Returns:

  • (String)

    output file format



13
14
15
16
17
# File 'lib/onlyoffice_documentserver_conversion_helper/xml_responce_parser.rb', line 13

def file_format
  return 'zip' if @result_in_zip

  @file_format
end

#result_urlString

Method parses server response returning url with unescape HTML

Returns:

  • (String)

    URL



22
23
24
25
# File 'lib/onlyoffice_documentserver_conversion_helper/xml_responce_parser.rb', line 22

def result_url
  res_result = /(http|https).*\.(#{file_format})/.match(@string_with_xml)
  CGI.unescapeHTML(res_result.to_s)
end