Class: Nfe::Models::Taxes::PISCOFINSAliq
- Inherits:
-
Object
- Object
- Nfe::Models::Taxes::PISCOFINSAliq
- Includes:
- ActiveModel::Model
- Defined in:
- lib/nfe/models/taxes/PISCOFINSAliq.rb
Instance Attribute Summary collapse
-
#cst ⇒ Object
Returns the value of attribute cst.
-
#tax ⇒ Object
Returns the value of attribute tax.
-
#value ⇒ Object
Returns the value of attribute value.
-
#vBC ⇒ Object
Returns the value of attribute vBC.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(xml_tax, xml_value) ⇒ PISCOFINSAliq
constructor
A new instance of PISCOFINSAliq.
- #parse!(xml) ⇒ Object
- #to_xml ⇒ Object
Constructor Details
#initialize(xml_tax, xml_value) ⇒ PISCOFINSAliq
Returns a new instance of PISCOFINSAliq.
35 36 37 38 |
# File 'lib/nfe/models/taxes/PISCOFINSAliq.rb', line 35 def initialize(xml_tax, xml_value) @xml_tax = xml_tax @xml_value = xml_value end |
Instance Attribute Details
#cst ⇒ Object
Returns the value of attribute cst.
7 8 9 |
# File 'lib/nfe/models/taxes/PISCOFINSAliq.rb', line 7 def cst @cst end |
#tax ⇒ Object
Returns the value of attribute tax.
7 8 9 |
# File 'lib/nfe/models/taxes/PISCOFINSAliq.rb', line 7 def tax @tax end |
#value ⇒ Object
Returns the value of attribute value.
7 8 9 |
# File 'lib/nfe/models/taxes/PISCOFINSAliq.rb', line 7 def value @value end |
#vBC ⇒ Object
Returns the value of attribute vBC.
7 8 9 |
# File 'lib/nfe/models/taxes/PISCOFINSAliq.rb', line 7 def vBC @vBC end |
Class Method Details
.csts ⇒ Object
9 10 11 |
# File 'lib/nfe/models/taxes/PISCOFINSAliq.rb', line 9 def self.csts ["01", "02"] end |
Instance Method Details
#parse!(xml) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/nfe/models/taxes/PISCOFINSAliq.rb', line 40 def parse!(xml) doc = Nokogiri::XML(xml) @cst = doc.css("CST").text.to_s @vBC = doc.css("vBC").text.to_f @tax = doc.css(@xml_tax).text.to_f @value = doc.css(@xml_value).text.to_f end |
#to_xml ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/nfe/models/taxes/PISCOFINSAliq.rb', line 49 def to_xml xml = Builder::XmlMarkup.new xml.CST "%2.2d" % @cst xml.vBC "%0.2f" % @vBC xml.tag!(@xml_tax) { |node| node << "%0.2f" % @tax } xml.tag!(@xml_value) { |node| node << "%0.2f" % @value } xml.target! end |