Module: TweetUrl::Username

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.username(object, parser = DEFAULT_PARSER) ⇒ String, NilClass

Take a URI string or URI object and return its username

Parameters:

  • object (String, URI)

    An ID, URI, or object.

Returns:

  • (String, NilClass)


8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/tweet_url/username.rb', line 8

def self.username(object, parser = DEFAULT_PARSER)
  case object
    when ::String
      Username::username(parser.parse(object), parser)
    when URI, parser
      Username::username(Uri.hashbang_path_or_path(object).split('/'))
    when Enumerable
      object[1]
    else
      nil
  end
end

Instance Method Details

#usernameObject



21
22
23
# File 'lib/tweet_url/username.rb', line 21

def username
  Username::username(@url, @parser)
end