Class: Twterm::Tab::Statuses::UserTimeline

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

Instance Attribute Summary collapse

Attributes included from Twterm::Tab::Scrollable

#scroller

Attributes included from Base

#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(user_id) ⇒ UserTimeline

Returns a new instance of UserTimeline.



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/twterm/tab/statuses/user_timeline.rb', line 31

def initialize(user_id)
  super()

  @user_id = user_id

  User.find_or_fetch(user_id).then do |user|
    @user = user
    TabManager.instance.refresh_window

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

Instance Attribute Details

#userObject (readonly)

Returns the value of attribute user.



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

def user
  @user
end

#user_idObject (readonly)

Returns the value of attribute user_id.



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

def user_id
  @user_id
end

Instance Method Details

#==(other) ⇒ Object



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

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

#closeObject



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

def close
  @auto_reloader.kill if @auto_reloader
  super
end

#dumpObject



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

def dump
  @user.id
end

#fetchObject



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

def fetch
  Client.current.user_timeline(@user.id).then do |statuses|
    statuses.reverse.each(&method(:prepend))
    sort
    yield if block_given?
  end
end

#titleObject



45
46
47
# File 'lib/twterm/tab/statuses/user_timeline.rb', line 45

def title
  @user.nil? ? 'Loading...' : "@#{@user.screen_name} timeline"
end