Sha256: 4683c82cd6962fbe8dca2522af6b37bae7ba427d57fc6ca47b2c03aa8cf326d9

Contents?: true

Size: 1.19 KB

Versions: 2

Compression:

Stored size: 1.19 KB

Contents

require 'twitter/default'
require 'twitter/tweet'

module Twitter
  module API
    # @note Inspired from twitter-4.5.0/spec/twitter/api/timelines_spec.rb
    module Timelines

      # Get some user timeline by screen name (last statuses)
      #
      # @param [String] screen_name the twitter user slug
      # @param [Hash] opts the options to retrieve the statuses
      # @option opts [Integer] :count The number of statuses to retrieve
      #
      # @example
      #   Twitter::Client.new.user_timeline('DolarBlue', count: 1)
      #   #=> [#<Twitter::Tweet:0x011.. @id="308609..., @text="Dolar Paralelo: $7,84.....
      def user_timeline(screen_name, opts)
        # Sanitize arguments
        count = opts[:count] || 1
        screen_name = screen_name.to_s
        # Work out
        results = get_user_timeline_results(screen_name, count)
        Twitter::Tweet.build_tweets(results)
      end

      private

      # (see #user_timeline)
      # @private
      def get_user_timeline_results(screen_name, count)
        path = "statuses/user_timeline.json"
        qry = []
        qry << ['screen_name', screen_name]
        qry << ['count', count.to_s]
        get(path, qry)
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
twitter_anonymous_client-1.0.1.0 lib/twitter/api/timelines.rb
twitter_anonymous_client-1.0.0.0 lib/twitter/api/timelines.rb