Sha256: 969e8c95dd5df05bd5e956ec60963ccef151089310ca4b92946add237108c5ae

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

module EnjuManifestationViewer
  module EnjuManifestation
    extend ActiveSupport::Concern

    included do

      def youtube_id
        if access_address
          url = ::Addressable::URI.parse(access_address)
          if url.host =~ /youtube\.com$/ && (url.path == "/watch")
            return CGI.parse(url.query)["v"][0]
          end
        end
      end

      def nicovideo_id
        if access_address
          url = ::Addressable::URI.parse(access_address)
          if url.host =~ /nicovideo\.jp$/ && url.path =~ /^\/watch/
            return url.path.split("/")[2]
          end
        end
      end

      def flickr
        if access_address
          url = ::Addressable::URI.parse(access_address)
          paths = url.path.split('/')
          if url.host =~ /^www\.flickr\.com$/ && (paths[1] == 'photos') && paths[2]
            info = {}
            if paths[3] == "sets"
              info[:user] = paths[2]
              info[:set_id] = paths[4]
              return info
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
enju_manifestation_viewer-0.4.0.rc.1 app/models/concerns/enju_manifestation_viewer/enju_manifestation.rb
enju_manifestation_viewer-0.4.0.beta.2 app/models/concerns/enju_manifestation_viewer/enju_manifestation.rb
enju_manifestation_viewer-0.4.0.beta.1 app/models/concerns/enju_manifestation_viewer/enju_manifestation.rb