Class: Twterm::Tab::New::List

Inherits:
Object
  • Object
show all
Includes:
FilterableList, Base, Scrollable
Defined in:
lib/twterm/tab/new/list.rb

Constant Summary collapse

@@lists =
nil

Instance Attribute Summary

Attributes included from Scrollable

#scroller

Attributes included from Base

#window

Instance Method Summary collapse

Methods included from FilterableList

#filter, #filter_query, #reset_filter

Methods included from Base

#close, #refresh, #resize

Constructor Details

#initializeList

Returns a new instance of List.



19
20
21
22
23
# File 'lib/twterm/tab/new/list.rb', line 19

def initialize
  super

  refresh
end

Instance Method Details

#==(other) ⇒ Object



11
12
13
# File 'lib/twterm/tab/new/list.rb', line 11

def ==(other)
  other.is_a?(self.class)
end

#drawable_item_countObject



15
16
17
# File 'lib/twterm/tab/new/list.rb', line 15

def drawable_item_count
  (window.maxy - 6).div(3)
end

#itemsObject



25
26
27
# File 'lib/twterm/tab/new/list.rb', line 25

def items
  (@@lists || []).select { |l| l.matches?(filter_query) }
end

#respond_to_key(key) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/twterm/tab/new/list.rb', line 29

def respond_to_key(key)
  return true if scroller.respond_to_key(key)

  case key
  when 10
    return true if current_list.nil?
    list_tab = Tab::Statuses::ListTimeline.new(current_list.id)
    TabManager.instance.switch(list_tab)
  when ?q
    reset_filter
  when ?/
    filter
  else
    return false
  end

  true
end

#titleObject



48
49
50
# File 'lib/twterm/tab/new/list.rb', line 48

def title
  'New tab'.freeze
end

#total_item_countObject



52
53
54
# File 'lib/twterm/tab/new/list.rb', line 52

def total_item_count
  items.count
end