Class: Twterm::Tweetbox
- Inherits:
-
Object
- Object
- Twterm::Tweetbox
- Includes:
- Curses, Readline, Singleton
- Defined in:
- lib/twterm/tweetbox.rb
Instance Method Summary collapse
- #clear ⇒ Object
- #compose(in_reply_to = nil) ⇒ Object
-
#initialize ⇒ Tweetbox
constructor
A new instance of Tweetbox.
- #post ⇒ Object
Constructor Details
#initialize ⇒ Tweetbox
Returns a new instance of Tweetbox.
7 8 9 |
# File 'lib/twterm/tweetbox.rb', line 7 def initialize @status = '' end |
Instance Method Details
#clear ⇒ Object
49 50 51 |
# File 'lib/twterm/tweetbox.rb', line 49 def clear @status = '' end |
#compose(in_reply_to = nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/twterm/tweetbox.rb', line 11 def compose(in_reply_to = nil) if in_reply_to.is_a? Status @in_reply_to = in_reply_to else @in_reply_to = nil end resetter = proc do reset_prog_mode sleep 0.1 Screen.instance.refresh end thread = Thread.new do close_screen puts "\ncompose new tweet:" @status = readline(@in_reply_to.nil? ? '> ' : " @#{in_reply_to.user.screen_name} ", true) resetter.call post end App.instance.register_interruption_handler do thread.kill clear puts "\ncanceled" resetter.call end thread.join end |