Class: Card::FollowerStash

Inherits:
Object
  • Object
show all
Defined in:
mod/follow/lib/card/follower_stash.rb

Overview

stash followers of a given card

Instance Method Summary collapse

Constructor Details

#initialize(card = nil) ⇒ FollowerStash

Returns a new instance of FollowerStash.



4
5
6
7
8
# File 'mod/follow/lib/card/follower_stash.rb', line 4

def initialize card=nil
  @stash = Hash.new { |h, v| h[v] = [] }
  @checked = ::Set.new
  check_card(card) if card
end

Instance Method Details

#check_card(card) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'mod/follow/lib/card/follower_stash.rb', line 10

def check_card card
  return if @checked.include? card.key

  Auth.as_bot do
    @checked.add card.key
    stash_direct_followers card
    stash_field_followers card.left
  end
end

#each_follower_with_reasonObject



24
25
26
27
28
29
# File 'mod/follow/lib/card/follower_stash.rb', line 24

def each_follower_with_reason
  # "follower"(=user) is a card object, "followed"(=reasons) a card name
  @stash.each do |follower_card, reasons|
    yield(follower_card, reasons.first)
  end
end

#followersObject



20
21
22
# File 'mod/follow/lib/card/follower_stash.rb', line 20

def followers
  @stash.keys
end