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

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

Instance Attribute Summary collapse

Attributes included from Twterm::Tab::Scrollable

#scroller

Attributes included from Base

#title, #window

Instance Method Summary collapse

Methods included from Dumpable

included

Methods included 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 Twterm::Tab::Scrollable

#total_item_count

Methods included from FilterableList

#filter, #filter_query, #items, #reset_filter

Methods included from Base

#refresh, #resize, #respond_to_key

Constructor Details

#initialize(query) ⇒ Search

Returns a new instance of Search.



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

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.



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

def query
  @query
end

Instance Method Details

#==(other) ⇒ Object



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

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

#closeObject



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

def close
  @auto_reloader.kill if @auto_reloader
  super
end

#dumpObject



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

def dump
  @query
end

#fetchObject



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

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