Sha256: e61168dee7a93a5f57918c5eecb40c5da7b7706e1375c7c51385506fca0d25ad

Contents?: true

Size: 906 Bytes

Versions: 54

Compression:

Stored size: 906 Bytes

Contents

# frozen_string_literal: true

module Pennyworth
  module Serializers
    # Serializes a HTTP status into a compatible format for parsing within Alfred script filters.
    class HTTPStatus
      def initialize presenter
        @presenter = presenter
      end

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

      private

      attr_reader :presenter

      def id = presenter.id

      def code = presenter.code

      def label = presenter.label

      def modifications
        {
          control: {subtitle: "Copy code.", arg: id},
          alt: {subtitle: "Copy label.", arg: label},
          cmd: {subtitle: "View documentation.", arg: presenter.url}
        }
      end
    end
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
pennyworth-17.3.0 lib/pennyworth/serializers/http_status.rb
pennyworth-17.2.0 lib/pennyworth/serializers/http_status.rb
pennyworth-17.1.0 lib/pennyworth/serializers/http_status.rb
pennyworth-17.0.0 lib/pennyworth/serializers/http_status.rb
pennyworth-16.7.0 lib/pennyworth/serializers/http_status.rb
pennyworth-16.5.0 lib/pennyworth/serializers/http_status.rb
pennyworth-16.4.0 lib/pennyworth/serializers/http_status.rb
pennyworth-16.3.0 lib/pennyworth/serializers/http_status.rb
pennyworth-16.2.0 lib/pennyworth/serializers/http_status.rb
pennyworth-16.1.0 lib/pennyworth/serializers/http_status.rb
pennyworth-16.0.0 lib/pennyworth/serializers/http_status.rb
pennyworth-15.4.1 lib/pennyworth/serializers/http_status.rb
pennyworth-15.4.0 lib/pennyworth/serializers/http_status.rb
pennyworth-15.3.0 lib/pennyworth/serializers/http_status.rb
pennyworth-15.2.0 lib/pennyworth/serializers/http_status.rb
pennyworth-15.1.1 lib/pennyworth/serializers/http_status.rb
pennyworth-15.1.0 lib/pennyworth/serializers/http_status.rb
pennyworth-15.0.3 lib/pennyworth/serializers/http_status.rb
pennyworth-15.0.2 lib/pennyworth/serializers/http_status.rb
pennyworth-15.0.1 lib/pennyworth/serializers/http_status.rb