Class: Nfe::Models::Taxes::PISCOFINSST
- Inherits:
-
Object
- Object
- Nfe::Models::Taxes::PISCOFINSST
- Includes:
- ActiveModel::Model
- Defined in:
- lib/nfe/models/taxes/PISCOFINSST.rb
Instance Attribute Summary collapse
-
#qBCProd ⇒ Object
Returns the value of attribute qBCProd.
-
#tax ⇒ Object
Returns the value of attribute tax.
-
#vAliqProd ⇒ Object
Returns the value of attribute vAliqProd.
-
#value ⇒ Object
Returns the value of attribute value.
-
#vBC ⇒ Object
Returns the value of attribute vBC.
Instance Method Summary collapse
-
#initialize(xml_tax, xml_value) ⇒ PISCOFINSST
constructor
A new instance of PISCOFINSST.
- #parse!(xml) ⇒ Object
- #present? ⇒ Boolean
- #to_xml ⇒ Object
Constructor Details
#initialize(xml_tax, xml_value) ⇒ PISCOFINSST
Returns a new instance of PISCOFINSST.
44 45 46 47 |
# File 'lib/nfe/models/taxes/PISCOFINSST.rb', line 44 def initialize(xml_tax, xml_value) @xml_tax = xml_tax @xml_value = xml_value end |
Instance Attribute Details
#qBCProd ⇒ Object
Returns the value of attribute qBCProd.
7 8 9 |
# File 'lib/nfe/models/taxes/PISCOFINSST.rb', line 7 def qBCProd @qBCProd end |
#tax ⇒ Object
Returns the value of attribute tax.
7 8 9 |
# File 'lib/nfe/models/taxes/PISCOFINSST.rb', line 7 def tax @tax end |
#vAliqProd ⇒ Object
Returns the value of attribute vAliqProd.
7 8 9 |
# File 'lib/nfe/models/taxes/PISCOFINSST.rb', line 7 def vAliqProd @vAliqProd end |
#value ⇒ Object
Returns the value of attribute value.
7 8 9 |
# File 'lib/nfe/models/taxes/PISCOFINSST.rb', line 7 def value @value end |
#vBC ⇒ Object
Returns the value of attribute vBC.
7 8 9 |
# File 'lib/nfe/models/taxes/PISCOFINSST.rb', line 7 def vBC @vBC end |
Instance Method Details
#parse!(xml) ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'lib/nfe/models/taxes/PISCOFINSST.rb', line 54 def parse!(xml) doc = Nokogiri::XML(xml) @vBC = doc.css("vBC").present? ? doc.css("vBC").text.to_f : nil @tax = doc.css(@xml_tax).present? ? doc.css(@xml_tax).text.to_f : nil @qBCProd = doc.css("qBCProd").present? ? doc.css("qBCProd").text.to_f : nil @vAliqProd = doc.css("vAliqProd").present? ? doc.css("vAliqProd").text.to_f : nil @value = doc.css(@xml_value).text.to_f end |
#present? ⇒ Boolean
49 50 51 52 |
# File 'lib/nfe/models/taxes/PISCOFINSST.rb', line 49 def present? @vBC.present? || @tax.present? || @qBCProd.present? || @vAliqProd.present? || @value.present? end |
#to_xml ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/nfe/models/taxes/PISCOFINSST.rb', line 64 def to_xml xml = Builder::XmlMarkup.new xml.vBC "%0.2f" % @vBC if @vBC.present? xml.tag!(@xml_tax) { |node| node << "%0.2f" % @tax } if @tax.present? xml.qBCProd "%0.4f" % @qBCProd if @qBCProd.present? xml.vAliqProd "%0.4f" % @vAliqProd if @vAliqProd.present? xml.tag!(@xml_value) { |node| node << "%0.2f" % @value } xml.target! end |