class Iqdb::Client::Parser::Response
Attributes
page[R]
Public Class Methods
new(html_text)
click to toggle source
# File lib/iqdb/client/parser/response.rb, line 5 def initialize(html_text) @page = Nokogiri::HTML.parse(html_text) end
Public Instance Methods
additional_matches()
click to toggle source
# File lib/iqdb/client/parser/response.rb, line 17 def additional_matches @additional_matches ||= find_page_by_text('Additional match').map { |match| Result.new(match) } end
best_match()
click to toggle source
# File lib/iqdb/client/parser/response.rb, line 13 def best_match @best_match ||= Result.new(find_page_by_text('Best match').first) end
possible_matches()
click to toggle source
# File lib/iqdb/client/parser/response.rb, line 21 def possible_matches @possible_matches ||= find_page_by_text('Possible match').map { |match| Result.new(match) } end
success?()
click to toggle source
# File lib/iqdb/client/parser/response.rb, line 9 def success? @success ||= find_page_by_text('No relevant matches').first.nil? end
Private Instance Methods
find_page_by_text(text)
click to toggle source
# File lib/iqdb/client/parser/response.rb, line 29 def find_page_by_text(text) pages.xpath(".//table[.//th[text() = \"#{text}\"]]") end
pages()
click to toggle source
# File lib/iqdb/client/parser/response.rb, line 33 def pages @pages ||= @page.xpath('//div[@id="pages"]') end