Class: Produto
- Inherits:
-
Object
- Object
- Produto
- Defined in:
- lib/nfe/entidades/infNFe/det/produto.rb
Overview
module NFe
Instance Attribute Summary collapse
-
#all_products ⇒ Object
Returns the value of attribute all_products.
-
#cEAN ⇒ Object
Returns the value of attribute cEAN.
-
#cEANTrib ⇒ Object
Returns the value of attribute cEANTrib.
-
#CFOP ⇒ Object
Returns the value of attribute CFOP.
-
#cProd ⇒ Object
Returns the value of attribute cProd.
-
#EXTIPI ⇒ Object
Returns the value of attribute EXTIPI.
-
#indTot ⇒ Object
Returns the value of attribute indTot.
-
#NCM ⇒ Object
Returns the value of attribute NCM.
-
#qCom ⇒ Object
Returns the value of attribute qCom.
-
#qTrib ⇒ Object
Returns the value of attribute qTrib.
-
#uCom ⇒ Object
Returns the value of attribute uCom.
-
#uTrib ⇒ Object
Returns the value of attribute uTrib.
-
#vProd ⇒ Object
Returns the value of attribute vProd.
-
#vUnCom ⇒ Object
Returns the value of attribute vUnCom.
-
#vUnTrib ⇒ Object
Returns the value of attribute vUnTrib.
-
#xPed ⇒ Object
Returns the value of attribute xPed.
-
#xProd ⇒ Object
Returns the value of attribute xProd.
Instance Method Summary collapse
- #attributes ⇒ Object
- #attributes=(params) ⇒ Object
-
#initialize(attrs = {}) ⇒ Produto
constructor
A new instance of Produto.
-
#xml_to_hash(xml) ⇒ Object
file xml.
Constructor Details
#initialize(attrs = {}) ⇒ Produto
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/nfe/entidades/infNFe/det/produto.rb', line 23 def initialize(attrs = {}) self.cProd = attrs[:cProd] self.cEAN = attrs[:cEAN] self.xProd = attrs[:xProd] self.NCM = attrs[:NCM] self.EXTIPI = attrs[:EXTIPI] self.CFOP = attrs[:CFOP] self.uCom = attrs[:uCom] self.qCom = attrs[:qCom] self.vUnCom = attrs[:vUnCom] self.vProd = attrs[:vProd] self.cEANTrib = attrs[:cEANTrib] self.uTrib = attrs[:uTrib] self.qTrib = attrs[:qTrib] self.vUnTrib = attrs[:vUnTrib] self.indTot = attrs[:indTot] self.xPed = attrs[:xPed] self.all_products = [] end |
Instance Attribute Details
#all_products ⇒ Object
Returns the value of attribute all_products.
21 22 23 |
# File 'lib/nfe/entidades/infNFe/det/produto.rb', line 21 def all_products @all_products end |
#cEAN ⇒ Object
Returns the value of attribute cEAN.
5 6 7 |
# File 'lib/nfe/entidades/infNFe/det/produto.rb', line 5 def cEAN @cEAN end |
#cEANTrib ⇒ Object
Returns the value of attribute cEANTrib.
14 15 16 |
# File 'lib/nfe/entidades/infNFe/det/produto.rb', line 14 def cEANTrib @cEANTrib end |
#CFOP ⇒ Object
Returns the value of attribute CFOP.
9 10 11 |
# File 'lib/nfe/entidades/infNFe/det/produto.rb', line 9 def CFOP @CFOP end |
#cProd ⇒ Object
Returns the value of attribute cProd.
4 5 6 |
# File 'lib/nfe/entidades/infNFe/det/produto.rb', line 4 def cProd @cProd end |
#EXTIPI ⇒ Object
Returns the value of attribute EXTIPI.
8 9 10 |
# File 'lib/nfe/entidades/infNFe/det/produto.rb', line 8 def EXTIPI @EXTIPI end |
#indTot ⇒ Object
Returns the value of attribute indTot.
18 19 20 |
# File 'lib/nfe/entidades/infNFe/det/produto.rb', line 18 def indTot @indTot end |
#NCM ⇒ Object
Returns the value of attribute NCM.
7 8 9 |
# File 'lib/nfe/entidades/infNFe/det/produto.rb', line 7 def NCM @NCM end |
#qCom ⇒ Object
Returns the value of attribute qCom.
11 12 13 |
# File 'lib/nfe/entidades/infNFe/det/produto.rb', line 11 def qCom @qCom end |
#qTrib ⇒ Object
Returns the value of attribute qTrib.
16 17 18 |
# File 'lib/nfe/entidades/infNFe/det/produto.rb', line 16 def qTrib @qTrib end |
#uCom ⇒ Object
Returns the value of attribute uCom.
10 11 12 |
# File 'lib/nfe/entidades/infNFe/det/produto.rb', line 10 def uCom @uCom end |
#uTrib ⇒ Object
Returns the value of attribute uTrib.
15 16 17 |
# File 'lib/nfe/entidades/infNFe/det/produto.rb', line 15 def uTrib @uTrib end |
#vProd ⇒ Object
Returns the value of attribute vProd.
13 14 15 |
# File 'lib/nfe/entidades/infNFe/det/produto.rb', line 13 def vProd @vProd end |
#vUnCom ⇒ Object
Returns the value of attribute vUnCom.
12 13 14 |
# File 'lib/nfe/entidades/infNFe/det/produto.rb', line 12 def vUnCom @vUnCom end |
#vUnTrib ⇒ Object
Returns the value of attribute vUnTrib.
17 18 19 |
# File 'lib/nfe/entidades/infNFe/det/produto.rb', line 17 def vUnTrib @vUnTrib end |
#xPed ⇒ Object
Returns the value of attribute xPed.
19 20 21 |
# File 'lib/nfe/entidades/infNFe/det/produto.rb', line 19 def xPed @xPed end |
#xProd ⇒ Object
Returns the value of attribute xProd.
6 7 8 |
# File 'lib/nfe/entidades/infNFe/det/produto.rb', line 6 def xProd @xProd end |
Instance Method Details
#attributes ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/nfe/entidades/infNFe/det/produto.rb', line 43 def attributes { "cProd" => cProd, "cEAN" => cEAN, "xProd" => xProd, "NCM" => NCM, "EXTIPI" => EXTIPI, "CFOP" => CFOP, "uCom" => uCom, "qCom" => qCom, "vUnCom" => vUnCom, "vProd" => vProd, "cEANTrib" => cEANTrib, "uTrib" => uTrib, "qTrib" => qTrib, "vUnTrib" => vUnTrib, "indTot" => indTot, "xPed" => xPed } end |
#attributes=(params) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/nfe/entidades/infNFe/det/produto.rb', line 63 def attributes=(params) self.cProd = params["cProd"] self.cEAN = params["cEAN"] self.xProd = params["xProd"] self.NCM = params["NCM"] self.EXTIPI = params["EXTIPI"] self.CFOP = params["CFOP"] self.uCom = params["uCom"] self.qCom = params["qCom"] self.vUnCom = params["vUnCom"] self.vProd = params["vProd"] self.cEANTrib = params["cEANTrib"] self.uTrib = params["uTrib"] self.qTrib = params["qTrib"] self.vUnTrib = params["vUnTrib"] self.indTot = params["indTot"] self.xPed = params["xPed"] end |
#xml_to_hash(xml) ⇒ Object
file xml
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/nfe/entidades/infNFe/det/produto.rb', line 82 def xml_to_hash(xml) #file xml doc = Nokogiri::XML(File.open(xml)) prods = doc.elements.css('prod').map do |p| { 'cProd' => p.css('cProd').text, 'cEAN' => p.css('cEAN').text, 'xProd' => p.css('xProd').text, 'NCM' => p.css('NCM').text, 'EXTIPI' => p.css('EXTIPI').text, 'CFOP' => p.css('CFOP').text, 'uCom' => p.css('uCom').text, 'qCom' => p.css('qCom').text, 'vUnCom' => p.css('vUnCom').text, 'vProd' => p.css('vProd').text, 'cEANTrib' => p.css('cEANTrib').text, 'uTrib' => p.css('uTrib').text, 'qTrib' => p.css('qTrib').text, 'vUnTrib' => p.css('vUnTrib').text, 'indTot' => p.css('indTot').text, 'xPed' => p.css('xPed').text } end prods.each {|p| self.all_products.push(p) } end |