Sha256: 33a2a1bae5fef151afc7a40b59e23c95a582d86714ad4d3925cc5ee43ffaecaa

Contents?: true

Size: 734 Bytes

Versions: 6

Compression:

Stored size: 734 Bytes

Contents

# frozen_string_literal: true

module Pennyworth
  module Serializers
    # Serializes an encoding presenter for parsing by Alfred script filters.
    class Encoding
      using Refinements::Array

      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

6 entries across 6 versions & 1 rubygems

Version Path
pennyworth-17.8.0 lib/pennyworth/serializers/encoding.rb
pennyworth-17.7.0 lib/pennyworth/serializers/encoding.rb
pennyworth-17.6.0 lib/pennyworth/serializers/encoding.rb
pennyworth-17.5.0 lib/pennyworth/serializers/encoding.rb
pennyworth-17.4.1 lib/pennyworth/serializers/encoding.rb
pennyworth-17.4.0 lib/pennyworth/serializers/encoding.rb