Class: Twterm::Tab::MentionsTab

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

Instance Attribute Summary

Attributes included from Base

#title

Instance Method Summary collapse

Methods included from StatusesTab

#append, #delete_status, #favorite, #open_link, #prepend, #reply, #respond_to_key, #retweet, #show_conversation, #show_user, #update

Methods included from AutoReloadable

#auto_reload

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(client) ⇒ MentionsTab

Returns a new instance of MentionsTab.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/twterm/tab/mentions_tab.rb', line 6

def initialize(client)
  fail ArgumentError, 'argument must be an instance of Client class' unless client.is_a? Client

  super()

  @client = client
  @client.on_mention do |status|
    prepend(status)
    Notifier.instance.show_message "Mentioned by @#{status.user.screen_name}: #{status.text}"
  end

  @title = 'Mentions'

  fetch { move_to_top }
  auto_reload(300) { fetch }
end

Instance Method Details

#closeObject



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

def close
  fail NotClosableError
end

#fetchObject



23
24
25
26
27
28
29
# File 'lib/twterm/tab/mentions_tab.rb', line 23

def fetch
  @client.mentions do |statuses|
    statuses.reverse.each(&method(:prepend))
    sort
    yield if block_given?
  end
end