Class: Nfe::WebService::SearchResult

Inherits:
Object
  • Object
show all
Defined in:
lib/nfe/web_service/search_result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(html_body) ⇒ SearchResult

Returns a new instance of SearchResult.



8
9
10
# File 'lib/nfe/web_service/search_result.rb', line 8

def initialize(html_body)
  self.body = html_body
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



6
7
8
# File 'lib/nfe/web_service/search_result.rb', line 6

def body
  @body
end

Instance Method Details

#messagesObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/nfe/web_service/search_result.rb', line 12

def messages
  return @msg if @msg
  nodes = Nokogiri::HTML(body).css('.tabela_resultado li').to_a
  @msg   = {}

  nodes[0..2].each do |node|
    @msg[gsub_key(node)] = gsub_message(node)
  end

  nodes[3].css('ul li').each do |node|
    @msg[gsub_key(node)] = gsub_message(node)
  end if nodes[3]

  @msg
end