Class: Ghn::Collector

Inherits:
Object
  • Object
show all
Defined in:
lib/ghn/collector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, repo_full_name = nil, options = {}) ⇒ Collector

Returns a new instance of Collector.



5
6
7
8
9
10
# File 'lib/ghn/collector.rb', line 5

def initialize(client, repo_full_name = nil, options = {})
  @client = client
  @repo_full_name = repo_full_name
  @follow_issuecomment = options[:follow_issuecomment] || false
  @participating = options[:participating] || false
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



3
4
5
# File 'lib/ghn/collector.rb', line 3

def client
  @client
end

#follow_issuecommentObject (readonly)

Returns the value of attribute follow_issuecomment.



3
4
5
# File 'lib/ghn/collector.rb', line 3

def follow_issuecomment
  @follow_issuecomment
end

#participatingObject (readonly)

Returns the value of attribute participating.



3
4
5
# File 'lib/ghn/collector.rb', line 3

def participating
  @participating
end

#repo_full_nameObject (readonly)

Returns the value of attribute repo_full_name.



3
4
5
# File 'lib/ghn/collector.rb', line 3

def repo_full_name
  @repo_full_name
end

Instance Method Details

#collect(page = 1) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ghn/collector.rb', line 12

def collect(page = 1)
  notifications = if repo_full_name
                    client.repo_notifications(repo_full_name, page: page, participating: participating)
                  else
                    client.notifications(page: page, participating: participating)
                  end
  @count = notifications.count
  notifications.map { |notification|
    Notification.new(notification, follow_issuecomment).type_class.new(notification, follow_issuecomment).url
  }.compact
end

#has_next?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/ghn/collector.rb', line 24

def has_next?
  @count == 50
end