Class: Twoffein::Tweet
- Inherits:
-
Object
- Object
- Twoffein::Tweet
- Defined in:
- lib/twoffein-client/tweet.rb
Instance Attribute Summary collapse
-
#drink ⇒ Object
Returns the value of attribute drink.
-
#target_screen_name ⇒ Object
Returns the value of attribute target_screen_name.
Instance Method Summary collapse
-
#initialize(drink_key, target_screen_name = nil) ⇒ Tweet
constructor
A new instance of Tweet.
- #post ⇒ Object (also: #publish)
- #to_s ⇒ Object
Constructor Details
#initialize(drink_key, target_screen_name = nil) ⇒ Tweet
Returns a new instance of Tweet.
10 11 12 13 |
# File 'lib/twoffein-client/tweet.rb', line 10 def initialize drink_key, target_screen_name=nil @drink = drink_key.to_sym @target_screen_name = target_screen_name end |
Instance Attribute Details
#drink ⇒ Object
Returns the value of attribute drink.
7 8 9 |
# File 'lib/twoffein-client/tweet.rb', line 7 def drink @drink end |
#target_screen_name ⇒ Object
Returns the value of attribute target_screen_name.
7 8 9 |
# File 'lib/twoffein-client/tweet.rb', line 7 def target_screen_name @target_screen_name end |
Instance Method Details
#post ⇒ Object Also known as: publish
15 16 17 18 19 20 21 22 |
# File 'lib/twoffein-client/tweet.rb', line 15 def post info = HTTP.post("tweet", { :drink => @drink, :target_screen_name => @target_screen_name }) raise Server::Error.new(info[:code], info[:error]) if info.has_key? :error info end |
#to_s ⇒ Object
25 26 27 28 29 |
# File 'lib/twoffein-client/tweet.rb', line 25 def to_s s = "Ich trinke gerade #{Drinks[@drink].name}" s << " mit #{@target_screen_name}" if @target_screen_name s << "." end |