Module: EnjuManifestationViewer::InstanceMethods

Defined in:
lib/enju_manifestation_viewer.rb

Instance Method Summary collapse

Instance Method Details

#flickrObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/enju_manifestation_viewer.rb', line 34

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

#nicovideo_idObject



25
26
27
28
29
30
31
32
# File 'lib/enju_manifestation_viewer.rb', line 25

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

#youtube_idObject



16
17
18
19
20
21
22
23
# File 'lib/enju_manifestation_viewer.rb', line 16

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