Sha256: daa7458242c7118397e09153cfa54d004e7029eaa70530d6854a499ec99b4252

Contents?: true

Size: 586 Bytes

Versions: 4

Compression:

Stored size: 586 Bytes

Contents

require 'youtube_id'
require File.expand_path('../default_url_strategy', __FILE__)

module FormattedURL
  module Strategies
    # Youtube Strategy to work with embed
    # and short formats
    class YoutubeURLStrategy < DefaultURLStrategy

      # Short path from youtube
      def short
        "http://youtu.be/#{youtube_id}"
      end

      # Embed format should be
      # used only with iframes
      def embed
        "http://youtube.com/embed/#{youtube_id}"
      end

      private

      def youtube_id # :nodoc:
        YoutubeID.from(self.path)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
formatted_url-0.0.6 lib/formatted_url/strategies/youtube_url_strategy.rb
formatted_url-0.0.5 lib/formatted_url/strategies/youtube_url_strategy.rb
formatted_url-0.0.4 lib/formatted_url/strategies/youtube_url_strategy.rb
formatted_url-0.0.3 lib/formatted_url/strategies/youtube_url_strategy.rb