Class: Twterm::Tab::Users::Base
Instance Attribute Summary collapse
Attributes inherited from Base
#window
Instance Method Summary
collapse
Methods included from Scrollable
#scroller, #total_item_count
Methods included from Loadable
#initially_loaded!, #initially_loaded?
Methods inherited from Base
#==, #close, #find_or_fetch_list, #find_or_fetch_status, #find_or_fetch_user, #render
Methods included from Subscriber
included, #subscribe, #unsubscribe
Constructor Details
#initialize(app, client) ⇒ Base
Returns a new instance of Base.
22
23
24
25
26
27
|
# File 'lib/twterm/tab/users/base.rb', line 22
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.
14
15
16
|
# File 'lib/twterm/tab/users/base.rb', line 14
def user_ids
@user_ids
end
|
Instance Method Details
#drawable_item_count ⇒ Object
16
17
18
|
# File 'lib/twterm/tab/users/base.rb', line 16
def drawable_item_count
(window.maxy - 6).div(3)
end
|
#fetch ⇒ Object
20
|
# File 'lib/twterm/tab/users/base.rb', line 20
def fetch; end
|
#items ⇒ Object
29
30
31
|
# File 'lib/twterm/tab/users/base.rb', line 29
def items
user_ids.map { |id| app.user_repository.find(id) }.compact
end
|
#matches?(user, query) ⇒ Boolean
33
34
35
36
37
38
39
|
# File 'lib/twterm/tab/users/base.rb', line 33
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/twterm/tab/users/base.rb', line 41
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
58
59
60
|
# File 'lib/twterm/tab/users/base.rb', line 58
def title
'User list'
end
|