Class: Twterm::Tab::New::User
- Inherits:
-
Base
- Object
- Base
- Twterm::Tab::New::User
show all
- Includes:
- Readline, Publisher
- Defined in:
- lib/twterm/tab/new/user.rb
Instance Attribute Summary
Attributes inherited from Base
#window
Instance Method Summary
collapse
Methods included from Publisher
#publish
Methods included from Utils
check_type
Methods inherited from Base
#close, #initialize, #refresh
Methods included from Subscriber
included, #subscribe, #unsubscribe
Instance Method Details
#==(other) ⇒ Object
11
12
13
|
# File 'lib/twterm/tab/new/user.rb', line 11
def ==(other)
other.is_a?(self.class)
end
|
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
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/twterm/tab/new/user.rb', line 15
def invoke_input
resetter = proc do
reset_prog_mode
sleep 0.1
Screen.instance.refresh
end
CompletionManager.instance.set_screen_name_mode!
input_thread = Thread.new do
close_screen
puts "\nSearch user"
screen_name = (readline('> @') || '').strip
resetter.call
if screen_name.nil? || screen_name.empty?
TabManager.instance.switch(Tab::New::Start.new)
else
Client.current.show_user(screen_name).then do |user|
if user.nil?
publish(Event::Notification.new(:error, 'User not found'))
tab = Tab::New::Start.new
else
tab = Tab::UserTab.new(user.id)
end
TabManager.instance.switch(tab)
end
end
end
App.instance.register_interruption_handler do
input_thread.kill
resetter.call
tab = Tab::New::Start.new
TabManager.instance.switch(tab)
end
input_thread.join
end
|
#respond_to_key(_) ⇒ Object
55
56
57
|
# File 'lib/twterm/tab/new/user.rb', line 55
def respond_to_key(_)
false
end
|
#title ⇒ Object
59
60
61
|
# File 'lib/twterm/tab/new/user.rb', line 59
def title
'New tab'.freeze
end
|