Sha256: 0c7eaed383b5bbc9b80e96658fba3db3c56fb5ca9b1e3a98ff3bce4c779b88f9

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module URLCanonicalize
  # The response from an HTTP request
  module Response
    class Generic
      attr_reader :url

      private

      def initialize(url)
        @url = url
      end
    end

    Redirect = Class.new(Generic)

    # Add HTML to a successful response
    class Success < Generic
      attr_reader :response, :html

      def xml
        @xml ||= Nokogiri::XML response.body
      end

      private

      def initialize(url, response, html)
        @response = response
        @html = html
        super(url)
      end
    end

    # We found a canonical URL!
    class CanonicalFound < Generic
      attr_reader :response

      private

      def initialize(url, response)
        @response = response
        super(url)
      end
    end

    # It barfed
    class Failure
      attr_reader :failure_class, :message

      private

      def initialize(failure_class, message)
        @failure_class = failure_class
        @message = message
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
url_canonicalize-1.0.0 lib/url_canonicalize/response.rb