Class: Twterm::Tab::Statuses::Conversation

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

Instance Attribute Summary collapse

Attributes included from Twterm::Tab::Scrollable

#scroller

Attributes inherited from Base

#window

Instance Method Summary collapse

Methods included from Dumpable

included

Methods inherited from Base

#append, #delete, #destroy_status, #drawable_item_count, #favorite, #fetch, #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

#close, #refresh, #respond_to_key

Constructor Details

#initialize(status_id) ⇒ Conversation

Returns a new instance of Conversation.



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/twterm/tab/statuses/conversation.rb', line 36

def initialize(status_id)
  super()

  Status.find_or_fetch(status_id).then do |status|
    @status = status

    append(status)
    scroller.move_to_top
    Thread.new { fetch_in_reply_to_status(status) }
    Thread.new { fetch_replies(status) }
  end
end

Instance Attribute Details

#statusObject (readonly)

Returns the value of attribute status.



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

def status
  @status
end

Instance Method Details

#==(other) ⇒ Object



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

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

#dumpObject



32
33
34
# File 'lib/twterm/tab/statuses/conversation.rb', line 32

def dump
  @status.id
end

#fetch_in_reply_to_status(status) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/twterm/tab/statuses/conversation.rb', line 15

def fetch_in_reply_to_status(status)
  status.in_reply_to_status.then do |in_reply_to|
    return if in_reply_to.nil?
    append(in_reply_to)
    sort
    Thread.new { fetch_in_reply_to_status(in_reply_to) }
  end
end

#fetch_replies(status) ⇒ Object



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

def fetch_replies(status)
  status.replies.each do |reply|
    prepend(reply)
    sort
    Thread.new { fetch_replies(reply) }
  end
end

#titleObject



49
50
51
# File 'lib/twterm/tab/statuses/conversation.rb', line 49

def title
  'Conversation'.freeze
end