Sha256: 9c3ebb466a07a5461625b70b9fa81fe2bcf47a46444a42e8ba64ae924a178658

Contents?: true

Size: 677 Bytes

Versions: 42

Compression:

Stored size: 677 Bytes

Contents

module Fog
  module Brightbox
    # Rough implementation to extract Brightbox identifiers from RFC5988 Link headers
    #
    # @see https://tools.ietf.org/html/rfc5988
    #
    class LinkHelper
      # @param [String] header The value assigned to the Link header
      def initialize(header)
        @header = header
        @parsed = false
      end

      def identifier
        parse unless @parsed
        uri.path.split("/")[3]
      end

      def uri
        parse unless @parsed
        URI.parse(@link)
      end

      private

      def parse
        match = @header.match(/\A<([^>]*)>/)
        @link = match[1]
        @parsed = true
      end
    end
  end
end

Version data entries

42 entries across 40 versions & 3 rubygems

Version Path
fog-brightbox-0.7.1 lib/fog/brightbox/link_helper.rb
fog-brightbox-0.7.0 lib/fog/brightbox/link_helper.rb