Class: Ksef::FA3::MetaEntry
- Inherits:
-
Data
- Object
- Data
- Ksef::FA3::MetaEntry
- Includes:
- Canonical
- Defined in:
- lib/ksef/fa3/meta_entry.rb,
lib/ksef/fa3/meta_entry.rb
Overview
Construction, invariants and serialisation for MetaEntry.
Constant Summary collapse
- NEEDS_BOTH =
"An attachment's metadata entry needs a key and a value. `ZKlucz` and " \ "`ZWartosc` are both mandatory within `MetaDane`."
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(key:, value:) ⇒ MetaEntry
constructor
A new instance of MetaEntry.
- #to_fa3(key_element:, value_element:) ⇒ Object
Methods included from Canonical
Constructor Details
#initialize(key:, value:) ⇒ MetaEntry
Returns a new instance of MetaEntry.
31 32 33 34 35 36 |
# File 'lib/ksef/fa3/meta_entry.rb', line 31 def initialize(key:, value:) canonical = { key: Formatting.text(key), value: Formatting.text(value) } raise ValidationError, NEEDS_BOTH if canonical.values.any? { |v| v.nil? || v.empty? } super(**canonical) end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key
18 19 20 |
# File 'lib/ksef/fa3/meta_entry.rb', line 18 def key @key end |
#value ⇒ Object (readonly)
Returns the value of attribute value
18 19 20 |
# File 'lib/ksef/fa3/meta_entry.rb', line 18 def value @value end |
Instance Method Details
#to_fa3(key_element:, value_element:) ⇒ Object
40 41 42 |
# File 'lib/ksef/fa3/meta_entry.rb', line 40 def to_fa3(key_element:, value_element:) { key_element => key, value_element => value } end |