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.
30 31 32 33 34 35 36 37 |
# File 'lib/newsman/issues.rb', line 30 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.
28 29 30 |
# File 'lib/newsman/issues.rb', line 28 def body @body end |
#number ⇒ Object
Returns the value of attribute number.
28 29 30 |
# File 'lib/newsman/issues.rb', line 28 def number @number end |
#repo ⇒ Object
Returns the value of attribute repo.
28 29 30 |
# File 'lib/newsman/issues.rb', line 28 def repo @repo end |
#title ⇒ Object
Returns the value of attribute title.
28 29 30 |
# File 'lib/newsman/issues.rb', line 28 def title @title end |
Instance Method Details
#detailed_title ⇒ Object
49 50 51 |
# File 'lib/newsman/issues.rb', line 49 def detailed_title "title: #{@title}, repo: #{@repo}, number: \##{@number}, url: #{url}, labels: #{labels}" end |
#important? ⇒ Boolean
71 72 73 |
# File 'lib/newsman/issues.rb', line 71 def important? labels.include? 'soon' end |
#labels ⇒ Object
57 58 59 |
# File 'lib/newsman/issues.rb', line 57 def labels @additional[:labels] end |
#to_json(*_args) ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/newsman/issues.rb', line 61 def to_json(*_args) { number: @number, title: @title, description: @body, repository: @repo, url: url.to_s }.to_json end |
#to_s ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/newsman/issues.rb', line 39 def to_s <<~MARKDOWN title: ```#{@title}```, description: ```#{@body}```, repo: ```#{@repo}```, issue number: \##{@number}, additional: #{@additional} MARKDOWN end |
#url ⇒ Object
53 54 55 |
# File 'lib/newsman/issues.rb', line 53 def url @additional[:url] end |