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.



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

#bodyObject

Returns the value of attribute body.



45
46
47
# File 'lib/newsman/issues.rb', line 45

def body
  @body
end

#numberObject

Returns the value of attribute number.



45
46
47
# File 'lib/newsman/issues.rb', line 45

def number
  @number
end

#repoObject

Returns the value of attribute repo.



45
46
47
# File 'lib/newsman/issues.rb', line 45

def repo
  @repo
end

#titleObject

Returns the value of attribute title.



45
46
47
# File 'lib/newsman/issues.rb', line 45

def title
  @title
end

Instance Method Details

#detailed_titleObject



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

Returns:

  • (Boolean)


88
89
90
# File 'lib/newsman/issues.rb', line 88

def important?
  labels.include? IMPORTANT_ISSUE
end

#labelsObject



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_sObject



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

#urlObject



70
71
72
# File 'lib/newsman/issues.rb', line 70

def url
  @additional[:url]
end