Sha256: c23898541616653615c71c845e06c62fd027bd5c9ee09bfb4a3d216aa44670bd

Contents?: true

Size: 798 Bytes

Versions: 6

Compression:

Stored size: 798 Bytes

Contents

module LinkShrink
  module Shrinkers
    # @author Jonah Ruiz <jonah@pixelhipsters.com>
    # Implements Tiny URL Shortener API
    class TinyUrl < Base
      # Returns URL base for API
      # @return [String] api base url
      def base_url
        'http://tinyurl.com/api-create.php'
      end

      # URL query parameters
      # @return [String] query parameters to be used in request
      def api_query_parameter
        "?url=#{url}"
      end

      # Returns Content-Type to be used in Request headers
      # @return [String] text/plain as content-type
      def content_type
        'text/plain'
      end

      # Returns full api url
      # @return [String] full api url with query parameters
      def api_url
        base_url.concat api_query_parameter
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
link_shrink-0.0.8 lib/link_shrink/shrinkers/tinyurl.rb
link_shrink-0.0.7 lib/link_shrink/shrinkers/tinyurl.rb
link_shrink-0.0.6 lib/link_shrink/shrinkers/tinyurl.rb
link_shrink-0.0.5 lib/link_shrink/shrinkers/tinyurl.rb
link_shrink-0.0.4 lib/link_shrink/shrinkers/tinyurl.rb
link_shrink-0.0.3 lib/link_shrink/shrinkers/tinyurl.rb