Class: Twterm::Tab::ListTab

Inherits:
Object
  • Object
show all
Includes:
Dumpable, StatusesTab
Defined in:
lib/twterm/tab/list_tab.rb

Instance Attribute Summary collapse

Attributes included from Base

#title

Instance Method Summary collapse

Methods included from Dumpable

included

Methods included from StatusesTab

#append, #delete, #destroy_status, #favorite, #open_link, #prepend, #reply, #respond_to_key, #retweet, #show_conversation, #show_user, #statuses, #touch_statuses, #update

Methods included from Scrollable

#count, #draw_scroll_bar, #index, #item_appended, #item_prepended, #last, #move_down, #move_to_bottom, #move_to_top, #move_up, #offset, #offset_from_bottom, #respond_to_key, #update_scrollbar_length

Methods included from Base

#refresh, #respond_to_key

Constructor Details

#initialize(list_id) ⇒ ListTab

Returns a new instance of ListTab.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/twterm/tab/list_tab.rb', line 9

def initialize(list_id)
  super()

  List.find_or_fetch(list_id) do |list|
    @list = list
    @title = @list.full_name
    TabManager.instance.refresh_window
    fetch { move_to_top }
    @auto_reloader = Scheduler.new(300) { fetch }
  end
end

Instance Attribute Details

#listObject (readonly)

Returns the value of attribute list.



7
8
9
# File 'lib/twterm/tab/list_tab.rb', line 7

def list
  @list
end

Instance Method Details

#==(other) ⇒ Object



35
36
37
# File 'lib/twterm/tab/list_tab.rb', line 35

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

#closeObject



30
31
32
33
# File 'lib/twterm/tab/list_tab.rb', line 30

def close
  @auto_reloader.kill if @auto_reloader
  super
end

#dumpObject



39
40
41
# File 'lib/twterm/tab/list_tab.rb', line 39

def dump
  @list.id
end

#fetchObject



21
22
23
24
25
26
27
28
# File 'lib/twterm/tab/list_tab.rb', line 21

def fetch
  client = Client.current
  client.list_timeline(@list) do |statuses|
    statuses.reverse.each(&method(:prepend))
    sort
    yield if block_given?
  end
end