Class: Iqdb::Client::Parser::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/iqdb/client/parser/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nokogiri_obj) ⇒ Result

Returns a new instance of Result.



7
8
9
# File 'lib/iqdb/client/parser/result.rb', line 7

def initialize(nokogiri_obj)
  @nokogiri_obj = nokogiri_obj
end

Instance Attribute Details

#nokogiri_objObject (readonly)

Returns the value of attribute nokogiri_obj.



5
6
7
# File 'lib/iqdb/client/parser/result.rb', line 5

def nokogiri_obj
  @nokogiri_obj
end

Instance Method Details

#altObject



15
16
17
# File 'lib/iqdb/client/parser/result.rb', line 15

def alt
  @alt ||= Alt.new(@nokogiri_obj.xpath('.//td[@class="image"]//img[1]/@alt').text)
end

#infoObject



19
20
21
# File 'lib/iqdb/client/parser/result.rb', line 19

def info
  { link: link, tags: alt.tags, rating: alt.rating }
end


11
12
13
# File 'lib/iqdb/client/parser/result.rb', line 11

def link
  @link ||= @nokogiri_obj.xpath('.//a[1]/@href').text
end