Class: ProductTaxonomy::Serializers::Attribute::Dist::TxtSerializer
- Inherits:
-
Object
- Object
- ProductTaxonomy::Serializers::Attribute::Dist::TxtSerializer
- Defined in:
- lib/product_taxonomy/models/serializers/attribute/dist/txt_serializer.rb
Class Method Summary collapse
- .serialize(attribute, padding: 0, locale: "en") ⇒ String
- .serialize_all(version:, locale: "en", padding: longest_gid_length) ⇒ Object
Class Method Details
.serialize(attribute, padding: 0, locale: "en") ⇒ String
28 29 30 |
# File 'lib/product_taxonomy/models/serializers/attribute/dist/txt_serializer.rb', line 28 def serialize(attribute, padding: 0, locale: "en") "#{attribute.gid.ljust(padding)} : #{attribute.name(locale:)}" end |
.serialize_all(version:, locale: "en", padding: longest_gid_length) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/product_taxonomy/models/serializers/attribute/dist/txt_serializer.rb', line 9 def serialize_all(version:, locale: "en", padding: longest_gid_length) header = <<~HEADER # Shopify Product Taxonomy - Attributes: #{version} # Format: {GID} : {Attribute name} HEADER attributes_txt = ProductTaxonomy::Attribute .sorted_base_attributes .map { serialize(_1, padding:, locale:) } .join("\n") header + attributes_txt end |