Module: TweetUrl::Status

Included in:
Base
Defined in:
lib/tweet_url/status.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.status_id(object, parser = DEFAULT_PARSER) ⇒ Integer, NilClass

Take a URI string or URI object and return its ID

Examples:

status_id = TweetUrl::Status::status_id('https://twitter.com/sferik/status/540897316908331009/')
status_id #=> 540897316908331009

Parameters:

  • object (Integer, String, URI)

    An ID, URI, or object.

Returns:

  • (Integer, NilClass)


12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/tweet_url/status.rb', line 12

def self.status_id(object, parser = DEFAULT_PARSER)
  case object
    when ::Integer
      object
    when ::String
      Status::status_id(parser.parse(object), parser)
    when parser
      Status::status_id(Uri.hashbang_path_or_path(object).split('/'))
    when Enumerable
      Uri::find_resource_id(object) {|s| /\Astatus(?:es)?\z/ === s}
    else
      nil
  end
end

Instance Method Details

#status_idObject



27
28
29
# File 'lib/tweet_url/status.rb', line 27

def status_id
  Status::status_id(@url, @parser)
end