Sha256: 45bf1473073d229791f80430370c8017063bbdc833d3d3d74d2106befd2c6389

Contents?: true

Size: 1.01 KB

Versions: 7

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module Pennyworth
  module Serializers
    module System
      # Serializes a system error presenter for parsing by 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

7 entries across 7 versions & 1 rubygems

Version Path
pennyworth-18.0.0 lib/pennyworth/serializers/system/error.rb
pennyworth-17.8.0 lib/pennyworth/serializers/system/error.rb
pennyworth-17.7.0 lib/pennyworth/serializers/system/error.rb
pennyworth-17.6.0 lib/pennyworth/serializers/system/error.rb
pennyworth-17.5.0 lib/pennyworth/serializers/system/error.rb
pennyworth-17.4.1 lib/pennyworth/serializers/system/error.rb
pennyworth-17.4.0 lib/pennyworth/serializers/system/error.rb