Sha256: 012a6ae7fe1e9b5e5f12e7404fdabf1bb5b2ce788dec3bd4466930bd5d82ca0a

Contents?: true

Size: 1.03 KB

Versions: 54

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module Pennyworth
  module Serializers
    module System
      # Serializes a system error into a compatible format for parsing within Alfred script filters.
      class Error
        def initialize presenter
          @presenter = presenter
        end

        def to_h
          {
            uid: id,
            title: id,
            subtitle: presenter.subtitle,
            arg: label,
            mods: modifications,
            text: {copy: label, largetype: label}
          }
        end

        private

        attr_reader :presenter

        def id = presenter.id

        def label = presenter.label

        def description = presenter.description

        def modifications
          {
            control: {subtitle: "Copy ID.", arg: id},
            alt: {subtitle: "Copy description.", arg: description},
            cmd: {
              subtitle: "Copy ID, name, and description.",
              arg: "#{id}, #{label}, #{description}"
            }
          }
        end
      end
    end
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
pennyworth-12.2.0 lib/pennyworth/serializers/system/error.rb
pennyworth-12.1.0 lib/pennyworth/serializers/system/error.rb
pennyworth-12.0.2 lib/pennyworth/serializers/system/error.rb
pennyworth-12.0.1 lib/pennyworth/serializers/system/error.rb
pennyworth-12.0.0 lib/pennyworth/serializers/system/error.rb
pennyworth-11.2.2 lib/pennyworth/serializers/system/error.rb
pennyworth-11.2.1 lib/pennyworth/serializers/system/error.rb
pennyworth-11.2.0 lib/pennyworth/serializers/system/error.rb
pennyworth-11.1.3 lib/pennyworth/serializers/system/error.rb
pennyworth-11.1.2 lib/pennyworth/serializers/system/error.rb
pennyworth-11.1.1 lib/pennyworth/serializers/system/error.rb
pennyworth-11.1.0 lib/pennyworth/serializers/system/error.rb
pennyworth-11.0.1 lib/pennyworth/serializers/system/error.rb
pennyworth-11.0.0 lib/pennyworth/serializers/system/error.rb