Class: ZATCA::Tag
- Inherits:
-
Object
- Object
- ZATCA::Tag
- Defined in:
- lib/zatca/tag.rb
Constant Summary collapse
- TAG_IDS =
{ seller_name: 1, vat_registration_number: 2, timestamp: 3, invoice_total: 4, vat_total: 5, xml_invoice_hash: 6, ecdsa_signature: 7, ecdsa_public_key: 8, ecdsa_stamp_signature: 9 # TODO: is this needed ? }.freeze
- PHASE_1_TAGS =
[ :seller_name, :vat_registration_number, :timestamp, :invoice_total, :vat_total ].freeze
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#key ⇒ Object
Returns the value of attribute key.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(key:, value:) ⇒ Tag
constructor
A new instance of Tag.
- #should_be_utf8_encoded? ⇒ Boolean
- #to_h ⇒ Object
- #to_tlv ⇒ Object
Constructor Details
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
23 24 25 |
# File 'lib/zatca/tag.rb', line 23 def id @id end |
#key ⇒ Object
Returns the value of attribute key.
23 24 25 |
# File 'lib/zatca/tag.rb', line 23 def key @key end |
#value ⇒ Object
Returns the value of attribute value.
23 24 25 |
# File 'lib/zatca/tag.rb', line 23 def value @value end |
Instance Method Details
#should_be_utf8_encoded? ⇒ Boolean
35 36 37 |
# File 'lib/zatca/tag.rb', line 35 def should_be_utf8_encoded? PHASE_1_TAGS.include?(key) end |
#to_h ⇒ Object
31 32 33 |
# File 'lib/zatca/tag.rb', line 31 def to_h {id: @id, key: @key, value: @value} end |
#to_tlv ⇒ Object
39 40 41 42 |
# File 'lib/zatca/tag.rb', line 39 def to_tlv tlv = @id.chr + @value.bytesize.chr + @value tlv.force_encoding("ASCII-8BIT") end |