Class: OmniparseClient::Parsers::HtmlParser
- Inherits:
-
Object
- Object
- OmniparseClient::Parsers::HtmlParser
- Includes:
- Connection, Loggable
- Defined in:
- lib/omni_parse_client_ruby/parsers/html_parser.rb
Overview
PARSER
Constant Summary
Constants included from Connection
Connection::CLIENT_ERRORS, Connection::DEFAULT_PORT, Connection::DEFAULT_URL, Connection::DEFAULT_VERSION, Connection::EXCEPTIONS_EXCLUDING_MESSAGES, Connection::EXCEPTIONS_INCLUDING_MESSAGES, Connection::MAX_RETRIES_COUNT, Connection::RETRIES_DELAYS_ARRAY
Instance Attribute Summary collapse
-
#html ⇒ Object
readonly
Returns the value of attribute html.
-
#omni_parser_id ⇒ Object
readonly
Returns the value of attribute omni_parser_id.
Attributes included from Loggable
Attributes included from Connection
#api_key, #host, #port, #version
Instance Method Summary collapse
-
#all ⇒ Object
fetching all parsers @omni_html.all(parser_id).
- #index_path ⇒ Object
-
#initialize(p = {}) ⇒ HtmlParser
constructor
A new instance of HtmlParser.
-
#params ⇒ Object
parsing params.
-
#parse(p = {}) ⇒ Object
Post parse run @omni_html.parse(parser_id, html).
-
#parse_path ⇒ Object
Paths.
-
#prepare(p = {}) ⇒ Object
preparing / building html params @omni_html.prepare(parser_id, html).
-
#trial_run(p = {}) ⇒ Object
Post trial run @omni_html.parse(parser_id, html).
- #trial_run_path ⇒ Object
Methods included from Connection
#base_url, #headers, #omni_get, #omni_post, #setup_connection, #test_connection, #test_connection_path
Constructor Details
#initialize(p = {}) ⇒ HtmlParser
Returns a new instance of HtmlParser.
16 17 18 |
# File 'lib/omni_parse_client_ruby/parsers/html_parser.rb', line 16 def initialize(p = {}) setup_connection(p) end |
Instance Attribute Details
#html ⇒ Object (readonly)
Returns the value of attribute html.
11 12 13 |
# File 'lib/omni_parse_client_ruby/parsers/html_parser.rb', line 11 def html @html end |
#omni_parser_id ⇒ Object (readonly)
Returns the value of attribute omni_parser_id.
11 12 13 |
# File 'lib/omni_parse_client_ruby/parsers/html_parser.rb', line 11 def omni_parser_id @omni_parser_id end |
Instance Method Details
#all ⇒ Object
fetching all parsers @omni_html.all(parser_id)
22 23 24 25 26 27 |
# File 'lib/omni_parse_client_ruby/parsers/html_parser.rb', line 22 def all self.last_request = base_url + index_path response = omni_get(last_request, {}, headers) self.last_response = Response.new(response) last_response end |
#index_path ⇒ Object
85 86 87 |
# File 'lib/omni_parse_client_ruby/parsers/html_parser.rb', line 85 def index_path "/#{version}/html_parsers" end |
#params ⇒ Object
parsing params
69 70 71 72 73 74 |
# File 'lib/omni_parse_client_ruby/parsers/html_parser.rb', line 69 def params { omni_parser_id: @omni_parser_id, html: @html } end |
#parse(p = {}) ⇒ Object
Post parse run @omni_html.parse(parser_id, html)
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/omni_parse_client_ruby/parsers/html_parser.rb', line 39 def parse(p = {}) return false unless p[:html] return false unless p[:omni_parser_id] prepare(p) self.last_request = base_url + parse_path response = omni_post(last_request, params, headers) self.last_response = Response.new(response) last_response end |
#parse_path ⇒ Object
Paths
77 78 79 |
# File 'lib/omni_parse_client_ruby/parsers/html_parser.rb', line 77 def parse_path "/#{version}/html_parser/parse" end |
#prepare(p = {}) ⇒ Object
preparing / building html params @omni_html.prepare(parser_id, html)
31 32 33 34 35 |
# File 'lib/omni_parse_client_ruby/parsers/html_parser.rb', line 31 def prepare(p = {}) @html = p[:html] @omni_parser_id = p[:omni_parser_id] true end |
#trial_run(p = {}) ⇒ Object
Post trial run @omni_html.parse(parser_id, html)
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/omni_parse_client_ruby/parsers/html_parser.rb', line 55 def trial_run(p = {}) return false unless p[:omni_parser_id] prepare(p) self.last_request = base_url + trial_run_path response = omni_post(last_request, params, headers) self.last_response = Response.new(response) last_response end |
#trial_run_path ⇒ Object
81 82 83 |
# File 'lib/omni_parse_client_ruby/parsers/html_parser.rb', line 81 def trial_run_path "/#{version}/html_parser/trial_run" end |