Class: LyreBird::Twitter

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/lyre_bird/twitter.rb

Instance Method Summary collapse

Constructor Details

#initialize(u, p) ⇒ Twitter

Returns a new instance of Twitter.



8
9
10
# File 'lib/lyre_bird/twitter.rb', line 8

def initialize(u, p)
  @auth = {:username => u, :password => p}
end

Instance Method Details

#mentions(which = :mentions, options = {}) ⇒ Object

which can be :friends, :user or :public options can be things like since, since_id, count, etc.



14
15
16
17
18
19
20
21
22
# File 'lib/lyre_bird/twitter.rb', line 14

def mentions(which=:mentions, options={})
  since_id = options[:since_id]
  options = {}
  options.merge!({:basic_auth => @auth})
  url =  "/statuses/#{which}.json?"
  url += "since_id=#{since_id}" unless since_id.nil?
  puts "Requesting #{url} from Twitter API using #{@auth.inspect}"
  self.class.get(url, options)      
end

#post(text) ⇒ Object



31
32
33
34
35
# File 'lib/lyre_bird/twitter.rb', line 31

def post(text)
  puts "POSTING TO TWITTER - " + text if $lyre_debug
  options = { :query => {:status => text}, :basic_auth => @auth }
  self.class.post('/statuses/update.json', options)
end

#timeline(which = :friends, options = {}) ⇒ Object

which can be :friends, :user or :public options can be things like since, since_id, count, etc.



26
27
28
29
# File 'lib/lyre_bird/twitter.rb', line 26

def timeline(which=:friends, options={})
  options.merge!({:basic_auth => @auth})
  self.class.get("/statuses/#{which}_timeline.json", options)
end