Sha256: a4d73e87dd676df3ac457579c903b759a670e8f6e5c1cdaaaccc43a064b9d479

Contents?: true

Size: 1.2 KB

Versions: 6

Compression:

Stored size: 1.2 KB

Contents

# extra.rb contains features that are not considered part of the core library.
# This file is not imported by doing <tt>require('twitter')</tt>, so you will 
# need to import this file separately like:
#  require('twitter')
#  require('twitter/extras')

require('twitter')

class Twitter::Client
  @@FEATURED_URIS = {
    :users => 'http://twitter.com/statuses/featured.json'
  }
  
  # Provides access to the Featured Twitter API.
  # 
  # Currently the only value for <tt>type</tt> accepted is <tt>:users</tt>,
  # which will return an Array of blessed Twitter::User objects that 
  # represent Twitter's featured users.
  def featured(type)
    uri = @@FEATURED_URIS[type]
    response = rest_oauth_connect(:get, uri)
    bless_models(Twitter::User.unmarshal(response.body))
  end
end

class Twitter::User
  class << self
    # Provides access to the Featured Twitter API via the Twitter4R Model 
    # interface.
    # 
    # The following lines of code are equivalent to each other:
    #  users1 = Twitter::User.features(client)
    #  users2 = client.featured(:users)
    # where <tt>users1</tt> and <tt>users2</tt> would be logically equivalent.
    def featured(client)
      client.featured(:users)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
twitter4r-0.7.0 lib/twitter/extras.rb
twitter4r-0.6.0 lib/twitter/extras.rb
twitter4r-0.5.3 lib/twitter/extras.rb
twitter4r-0.5.2 lib/twitter/extras.rb
twitter4r-0.5.1 lib/twitter/extras.rb
twitter4r-0.5.0 lib/twitter/extras.rb