Class: Crawlscope::IssueCollection
- Inherits:
-
Object
- Object
- Crawlscope::IssueCollection
- Includes:
- Enumerable
- Defined in:
- lib/crawlscope/issue_collection.rb
Instance Method Summary collapse
- #add(issue = nil, **attributes) ⇒ Object
- #any? ⇒ Boolean
- #by_category ⇒ Object
- #by_severity ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(issues = []) ⇒ IssueCollection
constructor
A new instance of IssueCollection.
- #size ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(issues = []) ⇒ IssueCollection
Returns a new instance of IssueCollection.
7 8 9 |
# File 'lib/crawlscope/issue_collection.rb', line 7 def initialize(issues = []) @issues = issues.dup end |
Instance Method Details
#add(issue = nil, **attributes) ⇒ Object
11 12 13 14 15 |
# File 'lib/crawlscope/issue_collection.rb', line 11 def add(issue = nil, **attributes) issue ||= Issue.new(**attributes) @issues << issue issue end |
#any? ⇒ Boolean
17 18 19 |
# File 'lib/crawlscope/issue_collection.rb', line 17 def any? @issues.any? end |
#by_category ⇒ Object
33 34 35 |
# File 'lib/crawlscope/issue_collection.rb', line 33 def by_category @issues.group_by(&:category) end |
#by_severity ⇒ Object
37 38 39 |
# File 'lib/crawlscope/issue_collection.rb', line 37 def by_severity @issues.group_by(&:severity) end |
#each(&block) ⇒ Object
21 22 23 |
# File 'lib/crawlscope/issue_collection.rb', line 21 def each(&block) @issues.each(&block) end |
#size ⇒ Object
25 26 27 |
# File 'lib/crawlscope/issue_collection.rb', line 25 def size @issues.size end |
#to_a ⇒ Object
29 30 31 |
# File 'lib/crawlscope/issue_collection.rb', line 29 def to_a @issues.dup end |