Skip to content

announce/tweet_url

Repository files navigation

TweetUrl

Build Status Gem Version

Installation

Add this line to your application's Gemfile:

gem 'tweet_url'

And then execute:

$ bundle

Or install it yourself as:

$ gem install tweet_url

Usage

Simply,

require 'tweet_url'

tweet_url = TweetUrl.parse('https://twitter.com/jack/status/761304654147784704/photo/1')
tweet_url.username  #=> "jack"
tweet_url.status_id  #=> 761304654147784704

To handle URL containing multibyte chars, run gem install addressable and

require 'addressable/uri'
require 'tweet_url'

tweet_url = TweetUrl.parse(
  'https://twitter.com/yukihiro_matz/status/755950562227605504#尾骶骨',
  parser: Addressable::URI)
tweet_url.username  #=> "yukihiro_matz"
tweet_url.status_id  #=> 755950562227605504