Class: Nfe::Xml

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml_or_file) ⇒ Xml

Returns a new instance of Xml.



8
9
10
11
# File 'lib/nfe/xml.rb', line 8

def initialize(xml_or_file)
  xml_or_file = File.read(xml_or_file) if File.exist?(xml_or_file)
  @xml_content = xml_or_file
end

Instance Attribute Details

#open_timeoutObject

Returns the value of attribute open_timeout.



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

def open_timeout
  @open_timeout
end

#read_timeoutObject

Returns the value of attribute read_timeout.



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

def read_timeout
  @read_timeout
end

#resultObject

Returns the value of attribute result.



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

def result
  @result
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


13
14
15
16
17
18
19
20
21
# File 'lib/nfe/xml.rb', line 13

def valid?
  case request
    when Net::HTTPSuccess then
      self.result = WebService::SearchResult.new(request.body)
      !request.body.include?('../Imagens/erro.png')
    else
      false
  end
end