Sha256: 40d7b0d2159292cc76842aef73cad046a95106aad10dd98969efc806d638e7ea

Contents?: true

Size: 753 Bytes

Versions: 21

Compression:

Stored size: 753 Bytes

Contents

# frozen_string_literal: true

module Pennyworth
  module Serializers
    # Serializes a encoding into a compatible format for parsing within Alfred script filters.
    class Encoding
      using Refinements::Arrays

      def initialize presenter
        @presenter = presenter
      end

      def to_h
        {
          uid: presenter.id,
          title: label,
          subtitle: %(Aliases: #{aliases.to_sentence}.),
          arg: label,
          mods: {
            alt: {subtitle: "Copy aliases.", arg: aliases.join(", ")}
          },
          text: {copy: label, largetype: label}
        }
      end

      private

      attr_reader :presenter

      def label = presenter.label

      def aliases = presenter.aliases
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
pennyworth-13.5.0 lib/pennyworth/serializers/encoding.rb