Class: Twterm::Tab::StatusTab
Instance Method Summary
collapse
Methods included from Scrollable
#scroller, #total_item_count
Methods included from Publisher
#publish
Methods included from Utils
check_type
Methods included from Dumpable
included
Methods inherited from AbstractTab
#==, #close, #find_or_fetch_list, #find_or_fetch_status, #find_or_fetch_user, #render
Methods included from Subscriber
included, #subscribe, #unsubscribe
Constructor Details
#initialize(app, client, status_id) ⇒ StatusTab
Returns a new instance of StatusTab.
21
22
23
24
25
|
# File 'lib/twterm/tab/status_tab.rb', line 21
def initialize(app, client, status_id)
super(app, client)
@status_id = status_id
end
|
Instance Method Details
#drawable_item_count ⇒ Object
27
28
29
|
# File 'lib/twterm/tab/status_tab.rb', line 27
def drawable_item_count
(window.maxy - status.text.split_by_width(window.maxx - 4).count - 6).div(2)
end
|
#dump ⇒ Object
31
32
33
|
# File 'lib/twterm/tab/status_tab.rb', line 31
def dump
status_id
end
|
#image ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/twterm/tab/status_tab.rb', line 35
def image
if status.nil?
find_or_fetch_status(status_id).then { render }
return Image.string('Loading...')
end
if user.nil?
find_or_fetch_user(status.user_id).then { render }
return Image.string('Loading...')
end
= [
ImageBuilder::UserNameImageBuilder.new(user).build,
Image.string(status.date.to_s).brackets,
(Image.whitespace.color(:black, :red) if status.favorited?),
(Image.whitespace.color(:black, :green) if status.),
((Image.number(status.favorite_count) - Image.plural(status.favorite_count, 'like')).color(:red) if status.favorite_count.positive?),
((Image.number(status.) - Image.plural(status., 'RT')).color(:green) if status..positive?),
].compact.intersperse(Image.whitespace).reduce(Image.empty, :-)
[
,
Image.blank_line,
*status.text.split_by_width(window.maxx - 4).map { |x| Image.string(x) },
Image.blank_line,
Image.blank_line,
*drawable_items.flat_map.with_index do |item, i|
curr = scroller.current_index?(i)
Image.cursor(1, curr) - Image.whitespace - image_for_item(item).bold(curr)
end.intersperse(Image.blank_line),
].reduce(Image.empty) { |acc, x| acc | x }
end
|
#items ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/twterm/tab/status_tab.rb', line 68
def items
[
:show_conversation,
:reply,
:favorite,
:retweet,
:quote,
(:destroy if user.id == client.user_id),
:show_user,
:open_in_browser,
*status.media,
*status.urls,
*status.hashtags,
*status.user_mentions,
].compact
end
|
#respond_to_key(key) ⇒ Object
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/twterm/tab/status_tab.rb', line 85
def respond_to_key(key)
return true if scroller.respond_to_key(key)
case key
when 10
perform_selected_action
else
return false
end
true
end
|
#title ⇒ Object
98
99
100
|
# File 'lib/twterm/tab/status_tab.rb', line 98
def title
user.nil? ? 'Loading...' : "@#{user.screen_name}'s tweet"
end
|