Class: Pry::SendTweet::SendTweet
Constant Summary
collapse
280
TimeAgoInWords::VERSION
Instance Method Summary
collapse
Methods inherited from BaseCommand
inherited
#page, #page_error, #page_ok
#render_user
#render_tweets
time_ago_in_words
Instance Method Details
#options(o) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/pry/send_tweet/commands/send_tweet.rb', line 13
def options(o)
o.on 'f=', 'file=',
'One or more paths to file(s) to attach to a tweet.',
as: Array
o.on 'r=', 'reply-to=',
'An absolute url to a tweet you want to reply to.'
o.on 's=', 'self-destruct=',
'The number of seconds (represented as a number or a timestamp in the ' \
'format of HH:MM:SS) to wait before automatically deleting the tweet ' \
'asynchronously.'
o.on 'd=', 'delay=',
'The number of seconds (represented as a number or a timestamp in the ' \
'format of HH:MM:SS) to wait before creating the tweet asynchronously.'
o.on 'n', 'no-newline',
"Remove newlines (\\n) from a tweet before sending it."
end
|
#process(args) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/pry/send_tweet/commands/send_tweet.rb', line 30
def process(args)
super
= ()
if opts.present?('delay')
time_obj, sleep_seconds = parse_duration_str(opts['delay'])
Thread.new {
sleep sleep_seconds
.call
}
publish_time = (time_obj ? time_obj : Time.now + sleep_seconds)
.getlocal
.strftime(time_format)
page_ok bold("Tweet will be published at approximately #{publish_time}.")
else
= .call
page_ok .url
end
end
|