Class: Twterm::Tab::UserTab

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

Instance Attribute Summary collapse

Attributes included from Scrollable

#scroller

Attributes included from Base

#title, #window

Instance Method Summary collapse

Methods included from Scrollable

#total_item_count

Methods included from Dumpable

included

Methods included from Base

#close, #refresh, #resize

Constructor Details

#initialize(user_id) ⇒ UserTab

Returns a new instance of UserTab.



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/twterm/tab/user_tab.rb', line 26

def initialize(user_id)
  super()

  self.title = 'Loading...'.freeze
  @user_id = user_id

  User.find_or_fetch(user_id).then do |user|
    refresh

    Client.current.lookup_friendships
    self.title = "@#{user.screen_name}"
  end
end

Instance Attribute Details

#user_idObject (readonly)

Returns the value of attribute user_id.



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

def user_id
  @user_id
end

Instance Method Details

#==(other) ⇒ Object



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

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

#drawable_item_countObject



18
19
20
# File 'lib/twterm/tab/user_tab.rb', line 18

def drawable_item_count
  (window.maxy - 11 - bio_height).div(2)
end

#dumpObject



14
15
16
# File 'lib/twterm/tab/user_tab.rb', line 14

def dump
  user_id
end

#fetchObject



22
23
24
# File 'lib/twterm/tab/user_tab.rb', line 22

def fetch
  update
end

#itemsObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/twterm/tab/user_tab.rb', line 40

def items
  items = %i(
    open_timeline_tab
    show_friends
    show_followers
    show_likes
  )
  items << :open_website  unless user.website.nil?
  items << :toggle_follow unless myself?
  items << :toggle_mute   unless myself?
  items << :toggle_block  unless myself?

  items
end

#respond_to_key(key) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/twterm/tab/user_tab.rb', line 55

def respond_to_key(key)
  return true if scroller.respond_to_key(key)

  case key
  when ?F
    follow unless myself?
  when 10
    perform_selected_action
  when ?t
    open_timeline_tab
  when ?W
    open_website
  else
    return false
  end

  true
end