Class: Ksef::FA3::TableColumn
- Inherits:
-
Data
- Object
- Data
- Ksef::FA3::TableColumn
- Includes:
- Canonical
- Defined in:
- lib/ksef/fa3/table_column.rb,
lib/ksef/fa3/table_column.rb
Overview
Construction, invariants and serialisation for TableColumn.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
-
.types ⇒ Array<String>
date,datetime,dec,int,time,txt.
Instance Method Summary collapse
-
#initialize(name:, type:) ⇒ TableColumn
constructor
A new instance of TableColumn.
- #to_fa3 ⇒ Object
Methods included from Canonical
Constructor Details
#initialize(name:, type:) ⇒ TableColumn
Returns a new instance of TableColumn.
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ksef/fa3/table_column.rb', line 33 def initialize(name:, type:) canonical = Formatting.text(type) unless self.class.types.include?(canonical) raise ValidationError, "Column type #{type.inspect} is not one FA(3) permits. `Kol/@Typ` allows " \ "#{self.class.types.join(", ")}." end super(name: Formatting.text(name).to_s, type: canonical) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name
13 14 15 |
# File 'lib/ksef/fa3/table_column.rb', line 13 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type
13 14 15 |
# File 'lib/ksef/fa3/table_column.rb', line 13 def type @type end |
Class Method Details
.types ⇒ Array<String>
Returns date, datetime, dec, int, time, txt.
21 22 23 24 25 26 |
# File 'lib/ksef/fa3/table_column.rb', line 21 def self.types Generated::Types::ALL .fetch("Faktura/Zalacznik/BlokDanych/Tabela/TNaglowek/Kol")[:attributes] .find { |attribute| attribute[:name] == "Typ" } .fetch(:values) end |
Instance Method Details
#to_fa3 ⇒ Object
44 45 46 |
# File 'lib/ksef/fa3/table_column.rb', line 44 def to_fa3 Serializer::Element.new(text: nil, attributes: { "Typ" => type }, children: { "NKom" => name }) end |