Class: Twterm::Tab::AbstractTab
- Inherits:
-
Object
- Object
- Twterm::Tab::AbstractTab
show all
- Includes:
- Curses, Subscriber
- Defined in:
- lib/twterm/tab/abstract_tab.rb
Direct Known Subclasses
KeyAssignmentsCheatsheet, New::Index, New::List, New::Search, New::User, Preferences::Index, Preferences::NotificationBackend, Preferences::PhotoViewerBackend, RateLimitStatus, StatusTab, Statuses::AbstractStatusesTab, UserListManagement, UserTab, Users::AbstractUsersTab
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Subscriber
included, #subscribe, #unsubscribe
Constructor Details
#initialize(app, client) ⇒ AbstractTab
Returns a new instance of AbstractTab.
54
55
56
57
58
59
60
|
# File 'lib/twterm/tab/abstract_tab.rb', line 54
def initialize(app, client)
@app, @client = app, client
@window = stdscr.subwin(stdscr.maxy - 5, stdscr.maxx, 3, 0)
subscribe(Event::Screen::Resize, :resize)
end
|
Instance Attribute Details
#title ⇒ Object
Returns the value of attribute title.
13
14
15
|
# File 'lib/twterm/tab/abstract_tab.rb', line 13
def title
@title
end
|
#window ⇒ Object
Returns the value of attribute window.
13
14
15
|
# File 'lib/twterm/tab/abstract_tab.rb', line 13
def window
@window
end
|
Instance Method Details
#==(other) ⇒ Object
15
16
17
|
# File 'lib/twterm/tab/abstract_tab.rb', line 15
def ==(other)
self.equal?(other)
end
|
#close ⇒ Object
19
20
21
22
|
# File 'lib/twterm/tab/abstract_tab.rb', line 19
def close
unsubscribe
window.close
end
|
#find_or_fetch_list(id) ⇒ Object
34
35
36
37
38
39
40
41
42
|
# File 'lib/twterm/tab/abstract_tab.rb', line 34
def find_or_fetch_list(id)
list = app.list_repository.find(id)
if list
Concurrent::Promise.fulfill(list)
else
client.list(id)
end
end
|
#find_or_fetch_status(id) ⇒ Object
24
25
26
27
28
29
30
31
32
|
# File 'lib/twterm/tab/abstract_tab.rb', line 24
def find_or_fetch_status(id)
status = app.status_repository.find(id)
if status
Concurrent::Promise.fulfill(status)
else
client.show_status(id)
end
end
|
#find_or_fetch_user(id) ⇒ Object
44
45
46
47
48
49
50
51
52
|
# File 'lib/twterm/tab/abstract_tab.rb', line 44
def find_or_fetch_user(id)
user = app.user_repository.find(id)
if user
Concurrent::Promise.fulfill(user)
else
client.show_user(id)
end
end
|
#render ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/twterm/tab/abstract_tab.rb', line 62
def render
Thread.new do
refresh_mutex.synchronize do
window.clear
window.with_color(:black, :transparent) do
(0...window.maxy).each do |i|
window.setpos(i, 0)
window.addch(' ')
end
end
view.at(1, 2).render
end if refreshable?
end
end
|
#respond_to_key(_) ⇒ Object
80
81
82
|
# File 'lib/twterm/tab/abstract_tab.rb', line 80
def respond_to_key(_)
fail NotImplementedError, 'respond_to_key method must be implemented'
end
|