Class: Twterm::Tweetbox

Inherits:
Object
  • Object
show all
Includes:
Readline, Publisher
Defined in:
lib/twterm/tweetbox.rb

Defined Under Namespace

Classes: EmptyTextError, TextTooLongError

Instance Method Summary collapse

Methods included from Publisher

#publish

Methods included from Utils

check_type

Constructor Details

#initialize(app, client) ⇒ Tweetbox

Returns a new instance of Tweetbox.



21
22
23
# File 'lib/twterm/tweetbox.rb', line 21

def initialize(app, client)
  @app, @client = app, client
end

Instance Method Details

#composeObject



25
26
27
# File 'lib/twterm/tweetbox.rb', line 25

def compose
  ask_and_post("\e[1mCompose new Tweet\e[0m", '> ', -> body { body })
end

#quote(status) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/twterm/tweetbox.rb', line 29

def quote(status)
  screen_name = app.user_repository.find(status.user_id).screen_name
  leading_text = "\e[1mQuoting @#{screen_name}'s Tweet\e[0m\n\n#{status.text}"
  prompt = '> '

  ask_and_post(leading_text, prompt, -> body { "#{body} #{status.url}" })
end

#reply(status) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/twterm/tweetbox.rb', line 37

def reply(status)
  screen_name = app.user_repository.find(status.user_id).screen_name
  leading_text = "\e[1mReplying to @#{screen_name}\e[0m\n\n#{status.text}"
  prompt = { prompt: '> ', init_text: "@#{screen_name} " }

  ask_and_post(leading_text, prompt, -> body { body }, { in_reply_to_status_id: status.id })
end