Class: Issue

Inherits:
Object
  • Object
show all
Defined in:
lib/newsman/issues.rb

Overview

This class represents a GitHub Issue abstraction created by a user.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, body, repo, number, **additional) ⇒ Issue

Returns a new instance of Issue.



32
33
34
35
36
37
38
39
# File 'lib/newsman/issues.rb', line 32

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

#bodyObject

Returns the value of attribute body.



30
31
32
# File 'lib/newsman/issues.rb', line 30

def body
  @body
end

#numberObject

Returns the value of attribute number.



30
31
32
# File 'lib/newsman/issues.rb', line 30

def number
  @number
end

#repoObject

Returns the value of attribute repo.



30
31
32
# File 'lib/newsman/issues.rb', line 30

def repo
  @repo
end

#titleObject

Returns the value of attribute title.



30
31
32
# File 'lib/newsman/issues.rb', line 30

def title
  @title
end

Instance Method Details

#detailed_titleObject



51
52
53
# File 'lib/newsman/issues.rb', line 51

def detailed_title
  "title: #{@title}, repo: #{@repo}, number: \##{@number}, url: #{url}, labels: #{labels}"
end

#important?Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/newsman/issues.rb', line 73

def important?
  labels.include? IMPORTANT_ISSUE
end

#labelsObject



59
60
61
# File 'lib/newsman/issues.rb', line 59

def labels
  @additional[:labels]
end

#to_json(*_args) ⇒ Object



63
64
65
66
67
68
69
70
71
# File 'lib/newsman/issues.rb', line 63

def to_json(*_args)
  {
    number: @number,
    title: @title,
    description: @body,
    repository: @repo,
    url: url.to_s
  }.to_json
end

#to_sObject



41
42
43
44
45
46
47
48
49
# File 'lib/newsman/issues.rb', line 41

def to_s
  <<~MARKDOWN
    title: ```#{@title}```,
    description: ```#{@body}```,
    repo: ```#{@repo}```,
    issue number: \##{@number},
    additional: #{@additional}
  MARKDOWN
end

#urlObject



55
56
57
# File 'lib/newsman/issues.rb', line 55

def url
  @additional[:url]
end