Sha256: 3b821dd79ed7d93b2f5aab52653a994d258c6e80426cc4ca89d18e1ad4573b2e

Contents?: true

Size: 1.95 KB

Versions: 7

Compression:

Stored size: 1.95 KB

Contents

module Tw
  class Client

    def mentions
      Twitter.mentions.map{|m|
        {
          :id => m.id,
          :user => m.user.screen_name,
          :text => m.text,
          :time => m.created_at
        }
      }
    end

    def search(word)
      Twitter.search(word).results.map{|m|
        {
          :id => m.id,
          :user => m.from_user,
          :text => m.text,
          :time => m.created_at
        }
      }
    end

    def home_timeline
      Twitter.home_timeline.map{|m|
        {
          :id => m.id,
          :user => m.user.screen_name,
          :text => m.text,
          :time => m.created_at
        }
      }
    end

    def user_timeline(user)
      Twitter.user_timeline(user).map{|m|
        {
          :id => m.id,
          :user => m.user.screen_name,
          :text => m.text,
          :time => m.created_at
        }
      }
    end

    def list_timeline(user,list)
      Twitter.list_timeline(user, list).map{|m|
        {
          :id => m.id,
          :user => m.user.screen_name,
          :text => m.text,
          :time => m.created_at
        }
      }
    end

    def direct_messages
      [Twitter.direct_messages.map{|m|
         {
           :id => m.id,
           :user => m.sender.screen_name,
           :text => m.text,
           :time => m.created_at
         }
       }, Twitter.direct_messages_sent.map{|m|
         {
           :id => m.id,
           :user => {
             :from => m.sender.screen_name,
             :to => m.recipient.screen_name
           },
           :text => m.text,
           :time => m.created_at
         }
       }].flatten
    end

    def tweet(message)
      res = Twitter.update message
      puts res.text
      puts "http://twitter.com/#{res.user.screen_name}/status/#{res.id}"
      puts res.created_at
    end

    def direct_message_create(to, message)
      res = Twitter.direct_message_create to, message
      puts res.text
      puts res.created_at
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
tw-0.2.4 lib/tw/client/request.rb
tw-0.2.3 lib/tw/client/request.rb
tw-0.2.2 lib/tw/client/request.rb
tw-0.2.1 lib/tw/client/request.rb
tw-0.2.0 lib/tw/client/request.rb
tw-0.1.1 lib/tw/client/request.rb
tw-0.1.0 lib/tw/client/request.rb