Class: Ghn::Collector
- Inherits:
-
Object
- Object
- Ghn::Collector
- Defined in:
- lib/ghn/collector.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#follow_issuecomment ⇒ Object
readonly
Returns the value of attribute follow_issuecomment.
-
#participating ⇒ Object
readonly
Returns the value of attribute participating.
-
#repo_full_name ⇒ Object
readonly
Returns the value of attribute repo_full_name.
Instance Method Summary collapse
- #collect(page = 1) ⇒ Object
- #has_next? ⇒ Boolean
-
#initialize(client, repo_full_name = nil, options = {}) ⇒ Collector
constructor
A new instance of Collector.
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, = {}) @client = client @repo_full_name = repo_full_name @follow_issuecomment = [:follow_issuecomment] || false @participating = [:participating] || false end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
3 4 5 |
# File 'lib/ghn/collector.rb', line 3 def client @client end |
#follow_issuecomment ⇒ Object (readonly)
Returns the value of attribute follow_issuecomment.
3 4 5 |
# File 'lib/ghn/collector.rb', line 3 def follow_issuecomment @follow_issuecomment end |
#participating ⇒ Object (readonly)
Returns the value of attribute participating.
3 4 5 |
# File 'lib/ghn/collector.rb', line 3 def participating @participating end |
#repo_full_name ⇒ Object (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
24 25 26 |
# File 'lib/ghn/collector.rb', line 24 def has_next? @count == 50 end |