Class: Issue
- Inherits:
-
Object
- Object
- Issue
- Defined in:
- lib/newsman/issues.rb
Overview
This class represents a GitHub Issue abstraction created by a user.
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#number ⇒ Object
Returns the value of attribute number.
-
#repo ⇒ Object
Returns the value of attribute repo.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
- #detailed_title ⇒ Object
- #important? ⇒ Boolean
-
#initialize(title, body, repo, number, **additional) ⇒ Issue
constructor
A new instance of Issue.
- #labels ⇒ Object
- #to_json(*_args) ⇒ Object
- #to_s ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(title, body, repo, number, **additional) ⇒ Issue
Returns a new instance of Issue.
47 48 49 50 51 52 53 54 |
# File 'lib/newsman/issues.rb', line 47 def initialize(title, body, repo, number, **additional) defaults = { url: 'undefined', labels: [] } @title = title @body = body @repo = repo @number = number @additional = defaults.merge(additional) end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
45 46 47 |
# File 'lib/newsman/issues.rb', line 45 def body @body end |
#number ⇒ Object
Returns the value of attribute number.
45 46 47 |
# File 'lib/newsman/issues.rb', line 45 def number @number end |
#repo ⇒ Object
Returns the value of attribute repo.
45 46 47 |
# File 'lib/newsman/issues.rb', line 45 def repo @repo end |
#title ⇒ Object
Returns the value of attribute title.
45 46 47 |
# File 'lib/newsman/issues.rb', line 45 def title @title end |
Instance Method Details
#detailed_title ⇒ Object
66 67 68 |
# File 'lib/newsman/issues.rb', line 66 def detailed_title "title: #{@title}, repo: #{@repo}, number: \##{@number}, url: #{url}, labels: #{labels}" end |
#important? ⇒ Boolean
88 89 90 |
# File 'lib/newsman/issues.rb', line 88 def important? labels.include? IMPORTANT_ISSUE end |
#labels ⇒ Object
74 75 76 |
# File 'lib/newsman/issues.rb', line 74 def labels @additional[:labels] end |
#to_json(*_args) ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'lib/newsman/issues.rb', line 78 def to_json(*_args) { number: @number, title: @title, description: @body, repository: @repo, url: url.to_s }.to_json end |
#to_s ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/newsman/issues.rb', line 56 def to_s <<~MARKDOWN title: ```#{@title}```, description: ```#{@body}```, repo: ```#{@repo}```, issue number: \##{@number}, additional: #{@additional} MARKDOWN end |
#url ⇒ Object
70 71 72 |
# File 'lib/newsman/issues.rb', line 70 def url @additional[:url] end |