Class: Twterm::Tab::AbstractTab
- Inherits:
-
Object
- Object
- Twterm::Tab::AbstractTab
- Includes:
- Subscriber
- Defined in:
- lib/twterm/tab/abstract_tab.rb
Direct Known Subclasses
KeyAssignmentsCheatsheet, New::Index, New::List, New::Search, New::User, Preferences::Control, Preferences::Index, Preferences::NotificationBackend, Preferences::PhotoViewerBackend, RateLimitStatus, StatusTab, Statuses::AbstractStatusesTab, UserListManagement, UserTab, Users::AbstractUsersTab
Instance Attribute Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Boolean
- #close ⇒ void
-
#find_or_fetch_list(id) ⇒ Concurrent::Promise<Twterm::List>
A utility method to find a list by their ID.
-
#find_or_fetch_status(id) ⇒ Concurrent::Promise<Twterm::Status>
A utility method to find a status by its ID.
-
#find_or_fetch_user(id) ⇒ Concurrent::Promise<Twterm::User>
A utility method to find a user by their id.
-
#initialize(app, client) ⇒ AbstractTab
constructor
A new instance of AbstractTab.
- #render ⇒ Object
- #respond_to_key(_) ⇒ Object
Methods included from Subscriber
included, #subscribe, #unsubscribe
Constructor Details
#initialize(app, client) ⇒ AbstractTab
Returns a new instance of AbstractTab.
65 66 67 |
# File 'lib/twterm/tab/abstract_tab.rb', line 65 def initialize(app, client) @app, @client = app, client end |
Instance Attribute Details
Instance Method Details
#==(other) ⇒ Boolean
17 18 19 |
# File 'lib/twterm/tab/abstract_tab.rb', line 17 def ==(other) self.equal?(other) end |
#close ⇒ void
This method returns an undefined value.
22 23 24 |
# File 'lib/twterm/tab/abstract_tab.rb', line 22 def close unsubscribe end |
#find_or_fetch_list(id) ⇒ Concurrent::Promise<Twterm::List>
A utility method to find a list by their ID
42 43 44 45 46 47 48 49 50 |
# File 'lib/twterm/tab/abstract_tab.rb', line 42 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) ⇒ Concurrent::Promise<Twterm::Status>
A utility method to find a status by its ID
29 30 31 32 33 34 35 36 37 |
# File 'lib/twterm/tab/abstract_tab.rb', line 29 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) ⇒ Concurrent::Promise<Twterm::User>
A utility method to find a user by their id
55 56 57 58 59 60 61 62 63 |
# File 'lib/twterm/tab/abstract_tab.rb', line 55 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
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/twterm/tab/abstract_tab.rb', line 69 def render Thread.new do refresh_mutex.synchronize do window.clear # avoid misalignment caused by some multibyte-characters window.with_color(:black, :transparent) do (0...window.maxy).each do |i| window.setpos(i, 0) window.addch(' ') end end view.render end if refreshable? end end |
#respond_to_key(_) ⇒ Object
87 88 89 |
# File 'lib/twterm/tab/abstract_tab.rb', line 87 def respond_to_key(_) fail NotImplementedError, 'respond_to_key method must be implemented' end |