Class: Twterm::Tab::Statuses::Favorites
- Inherits:
-
Object
- Object
- Twterm::Tab::Statuses::Favorites
- Defined in:
- lib/twterm/tab/statuses/favorites.rb
Instance Attribute Summary collapse
-
#user ⇒ Object
readonly
Returns the value of attribute user.
-
#user_id ⇒ Object
readonly
Returns the value of attribute user_id.
Attributes included from Twterm::Tab::Scrollable
Attributes included from Base
Instance Method Summary collapse
- #==(other) ⇒ Object
- #dump ⇒ Object
- #fetch ⇒ Object
-
#initialize(user_id) ⇒ Favorites
constructor
A new instance of Favorites.
- #title ⇒ Object
Methods included from Dumpable
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
Methods included from FilterableList
#filter, #filter_query, #items, #reset_filter
Methods included from Base
#close, #refresh, #resize, #respond_to_key
Constructor Details
#initialize(user_id) ⇒ Favorites
Returns a new instance of Favorites.
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/twterm/tab/statuses/favorites.rb', line 26 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 } end end |
Instance Attribute Details
#user ⇒ Object (readonly)
Returns the value of attribute user.
8 9 10 |
# File 'lib/twterm/tab/statuses/favorites.rb', line 8 def user @user end |
#user_id ⇒ Object (readonly)
Returns the value of attribute user_id.
8 9 10 |
# File 'lib/twterm/tab/statuses/favorites.rb', line 8 def user_id @user_id end |
Instance Method Details
#==(other) ⇒ Object
10 11 12 |
# File 'lib/twterm/tab/statuses/favorites.rb', line 10 def ==(other) other.is_a?(self.class) && user_id == other.user_id end |
#dump ⇒ Object
14 15 16 |
# File 'lib/twterm/tab/statuses/favorites.rb', line 14 def dump @user.id end |
#fetch ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/twterm/tab/statuses/favorites.rb', line 18 def fetch Client.current.favorites(@user.id).then do |statuses| statuses.reverse.each(&method(:prepend)) sort yield if block_given? end end |
#title ⇒ Object
39 40 41 |
# File 'lib/twterm/tab/statuses/favorites.rb', line 39 def title @user.nil? ? 'Loading...' : "@#{@user.screen_name} likes" end |