Module: Tweet
- Defined in:
- lib/tweet.rb
Constant Summary collapse
- CONFIG_FILE =
ENV['HOME']+'/.tweet'
Class Attribute Summary collapse
-
.password ⇒ Object
Returns the value of attribute password.
-
.username ⇒ Object
Returns the value of attribute username.
Class Method Summary collapse
Class Attribute Details
.password ⇒ Object
Returns the value of attribute password.
10 11 12 |
# File 'lib/tweet.rb', line 10 def password @password end |
.username ⇒ Object
Returns the value of attribute username.
10 11 12 |
# File 'lib/tweet.rb', line 10 def username @username end |
Class Method Details
.create_status(status) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/tweet.rb', line 12 def create_status(status) len = status.length abort "Message limit is 140 characters. You currently have #{len}" if len > 140 get_credentials! resource = RestClient::Resource.new 'http://twitter.com/statuses/update.xml', username, password resource.post(:status => status, :source => 'tweetgem', :content_type => 'application/xml', :accept => 'application/xml') puts "#{len} chars" + (len == 140 ? "!\nYou rock!" : '.') end |
.get_credentials! ⇒ Object
21 22 23 24 25 |
# File 'lib/tweet.rb', line 21 def get_credentials! abort "You must create a #{CONFIG_FILE} file to use this CLI." unless File.exist?(CONFIG_FILE) config = YAML.load(File.read(CONFIG_FILE)).symbolize_keys @username, @password = config[:username], config[:password] end |