Module: TweetUrl::Uri

Defined in:
lib/tweet_url/uri.rb

Class Method Summary collapse

Class Method Details

.find_resource_id(list, &block) ⇒ Integer, NilClass

Retrieves REST resource ID

Parameters:

  • list (String[])
  • &block (Proc)

Returns:

  • (Integer, NilClass)


8
9
10
11
12
13
# File 'lib/tweet_url/uri.rb', line 8

def self.find_resource_id(list, &block)
  index = list.index(&block)
  return index if index.nil?
  target = list[index + 1]
  target.nil? ? target : target.to_i
end

.hashbang_path_or_path(object) ⇒ String

To support old style URL like twitter.com/#!/status/759813164686938117

Parameters:

  • object (URI)

Returns:

  • (String)


18
19
20
21
22
# File 'lib/tweet_url/uri.rb', line 18

def self.hashbang_path_or_path(object)
  (not object.fragment.nil? and object.fragment.chars.first == '!') ?
      object.fragment :
      object.path
end