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.
-
.shorten_urls ⇒ Object
Returns the value of attribute shorten_urls.
-
.username ⇒ Object
Returns the value of attribute username.
Class Method Summary collapse
Class Attribute Details
.password ⇒ Object
Returns the value of attribute password.
11 12 13 |
# File 'lib/tweet.rb', line 11 def password @password end |
.shorten_urls ⇒ Object
Returns the value of attribute shorten_urls.
11 12 13 |
# File 'lib/tweet.rb', line 11 def shorten_urls @shorten_urls end |
.username ⇒ Object
Returns the value of attribute username.
11 12 13 |
# File 'lib/tweet.rb', line 11 def username @username end |
Class Method Details
.create_status(status) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/tweet.rb', line 13 def create_status(status) get_credentials! resource = RestClient::Resource.new 'http://twitter.com/statuses/update.xml', username, password status = minify_urls_in_status(status) if shorten_urls resource.post(:status => status, :source => 'tweetgem', :content_type => 'application/xml', :accept => 'application/xml') end |
.get_credentials! ⇒ Object
20 21 22 23 24 |
# File 'lib/tweet.rb', line 20 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, @shorten_urls = config[:username], config[:password], config[:shorten_urls] end |