Sha256: c37d8631030be99d25e268a689fccaebb4e9b248a898ae6f741aa51fefea2a7e

Contents?: true

Size: 925 Bytes

Versions: 43

Compression:

Stored size: 925 Bytes

Contents

# frozen_string_literal: true

require "forwardable"
require "refinements/strings"

module Pennyworth
  module Presenters
    # Renders system error into a compatible format for use in Alfred script filters.
    class HTTPStatus
      extend Forwardable

      using Refinements::Strings

      delegate %i[code label url] => :record

      def initialize record, inflector: Inflector.new
        @record = record
        @inflector = inflector
      end

      def id = record.code

      def subtitle = "#{id} #{label}"

      def symbol = ":#{inflector.call name}"

      private

      attr_reader :record, :inflector

      def name
        label.snakecase
             .tr("/", "_")
             .gsub(/(\(|\))/, "")
             .sub("h_t_t_p_version_not_supported", "http_version_not_supported")
             .sub("i_m_used", "im_used")
             .sub("u_r_i_too_long", "uri_too_long")
      end
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
pennyworth-15.4.1 lib/pennyworth/presenters/http_status.rb
pennyworth-15.4.0 lib/pennyworth/presenters/http_status.rb
pennyworth-15.3.0 lib/pennyworth/presenters/http_status.rb
pennyworth-15.2.0 lib/pennyworth/presenters/http_status.rb
pennyworth-15.1.1 lib/pennyworth/presenters/http_status.rb
pennyworth-15.1.0 lib/pennyworth/presenters/http_status.rb
pennyworth-15.0.3 lib/pennyworth/presenters/http_status.rb
pennyworth-15.0.2 lib/pennyworth/presenters/http_status.rb
pennyworth-15.0.1 lib/pennyworth/presenters/http_status.rb
pennyworth-15.0.0 lib/pennyworth/presenters/http_status.rb
pennyworth-14.3.0 lib/pennyworth/presenters/http_status.rb
pennyworth-14.2.1 lib/pennyworth/presenters/http_status.rb
pennyworth-14.2.0 lib/pennyworth/presenters/http_status.rb
pennyworth-14.1.2 lib/pennyworth/presenters/http_status.rb
pennyworth-14.1.1 lib/pennyworth/presenters/http_status.rb
pennyworth-14.1.0 lib/pennyworth/presenters/http_status.rb
pennyworth-14.0.0 lib/pennyworth/presenters/http_status.rb
pennyworth-13.8.0 lib/pennyworth/presenters/http_status.rb
pennyworth-13.7.0 lib/pennyworth/presenters/http_status.rb
pennyworth-13.6.0 lib/pennyworth/presenters/http_status.rb