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.



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

#bodyObject

Returns the value of attribute body.



28
29
30
# File 'lib/newsman/issues.rb', line 28

def body
  @body
end

#numberObject

Returns the value of attribute number.



28
29
30
# File 'lib/newsman/issues.rb', line 28

def number
  @number
end

#repoObject

Returns the value of attribute repo.



28
29
30
# File 'lib/newsman/issues.rb', line 28

def repo
  @repo
end

#titleObject

Returns the value of attribute title.



28
29
30
# File 'lib/newsman/issues.rb', line 28

def title
  @title
end

Instance Method Details

#detailed_titleObject



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

Returns:

  • (Boolean)


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

def important?
  labels.include? 'soon'
end

#labelsObject



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_sObject



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

#urlObject



53
54
55
# File 'lib/newsman/issues.rb', line 53

def url
  @additional[:url]
end