Class: Twterm::Tab::Statuses::Search

Inherits:
Base
  • Object
show all
Includes:
Dumpable
Defined in:
lib/twterm/tab/statuses/search.rb

Instance Attribute Summary collapse

Attributes included from Twterm::Tab::Scrollable

#scroller

Attributes inherited from Base

#title, #window

Instance Method Summary collapse

Methods included from Dumpable

included

Methods inherited from Base

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

Methods included from Utils

check_type

Methods included from Subscriber

included, #subscribe, #unsubscribe

Methods included from Twterm::Tab::Scrollable

#total_item_count

Methods included from Publisher

#publish

Methods included from FilterableList

#filter, #filter_query, #items, #reset_filter

Methods inherited from Base

#refresh, #respond_to_key

Constructor Details

#initialize(query) ⇒ Search

Returns a new instance of Search.



32
33
34
35
36
37
38
39
40
# File 'lib/twterm/tab/statuses/search.rb', line 32

def initialize(query)
  super()

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

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

Instance Attribute Details

#queryObject (readonly)

Returns the value of attribute query.



9
10
11
# File 'lib/twterm/tab/statuses/search.rb', line 9

def query
  @query
end

Instance Method Details

#==(other) ⇒ Object



11
12
13
# File 'lib/twterm/tab/statuses/search.rb', line 11

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

#closeObject



15
16
17
18
# File 'lib/twterm/tab/statuses/search.rb', line 15

def close
  @auto_reloader.kill if @auto_reloader
  super
end

#dumpObject



20
21
22
# File 'lib/twterm/tab/statuses/search.rb', line 20

def dump
  @query
end

#fetchObject



24
25
26
27
28
29
30
# File 'lib/twterm/tab/statuses/search.rb', line 24

def fetch
  Client.current.search(@query).then do |statuses|
    statuses.each(&method(:append))
    sort
    yield if block_given?
  end
end