Class: Twterm::Tab::Users::AbstractUsersTab
Instance Attribute Summary collapse
Attributes inherited from AbstractTab
#window
Instance Method Summary
collapse
Methods included from Scrollable
#scroller, #total_item_count
Methods included from Loadable
#initially_loaded!, #initially_loaded?
Methods inherited from AbstractTab
#==, #close, #find_or_fetch_list, #find_or_fetch_status, #find_or_fetch_user, #render
Methods included from Subscriber
included, #subscribe, #unsubscribe
Constructor Details
Returns a new instance of AbstractUsersTab.
23
24
25
26
27
28
|
# File 'lib/twterm/tab/users/abstract_users_tab.rb', line 23
def initialize(app, client)
super(app, client)
@user_ids = Concurrent::Array.new
subscribe(Event::UserGarbageCollected) { |id| @user_ids.delete(id) }
end
|
Instance Attribute Details
#user_ids ⇒ Object
Returns the value of attribute user_ids.
15
16
17
|
# File 'lib/twterm/tab/users/abstract_users_tab.rb', line 15
def user_ids
@user_ids
end
|
Instance Method Details
#drawable_item_count ⇒ Object
17
18
19
|
# File 'lib/twterm/tab/users/abstract_users_tab.rb', line 17
def drawable_item_count
(window.maxy - 6).div(3)
end
|
#fetch ⇒ Object
21
|
# File 'lib/twterm/tab/users/abstract_users_tab.rb', line 21
def fetch; end
|
#items ⇒ Object
30
31
32
|
# File 'lib/twterm/tab/users/abstract_users_tab.rb', line 30
def items
user_ids.map { |id| app.user_repository.find(id) }.compact
end
|
#matches?(user, query) ⇒ Boolean
34
35
36
37
38
39
40
|
# File 'lib/twterm/tab/users/abstract_users_tab.rb', line 34
def matches?(user, query)
[
user.name,
user.screen_name,
user.description
].compact.any? { |x| x.downcase.include?(query.downcase) }
end
|
#respond_to_key(key) ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/twterm/tab/users/abstract_users_tab.rb', line 42
def respond_to_key(key)
return true if scroller.respond_to_key(key)
k = KeyMapper.instance
case key
when 10
show_user
when k[:tab, :reload]
fetch
else
return false
end
true
end
|
#title ⇒ Object
59
60
61
|
# File 'lib/twterm/tab/users/abstract_users_tab.rb', line 59
def title
'User list'
end
|