Class: Twterm::Tab::SearchTab

Inherits:
Object
  • Object
show all
Includes:
Dumpable, StatusesTab
Defined in:
lib/twterm/tab/search_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(query) ⇒ SearchTab

Returns a new instance of SearchTab.



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

def initialize(query)
  super()

  @query = query
  @title = "\"#{@query}\""

  fetch { move_to_top }
  @auto_reloader = Scheduler.new(300) { fetch }
end

Instance Attribute Details

#queryObject (readonly)

Returns the value of attribute query.



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

def query
  @query
end

Instance Method Details

#==(other) ⇒ Object



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

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

#closeObject



26
27
28
29
# File 'lib/twterm/tab/search_tab.rb', line 26

def close
  @auto_reloader.kill if @auto_reloader
  super
end

#dumpObject



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

def dump
  @query
end

#fetchObject



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

def fetch
  Client.current.search(@query) do |statuses|
    statuses.reverse.each { |status| prepend(status) }
    yield if block_given?
  end
end