Class: ChangelogGenerator::Issue

Inherits:
Object
  • Object
show all
Defined in:
lib/changelog_generator/issue.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Issue

Returns a new instance of Issue.



13
14
15
16
17
# File 'lib/changelog_generator/issue.rb', line 13

def initialize(args)
  args.each do |k,v|
    instance_variable_set("@#{k}", v) unless v.nil?
  end
end

Instance Attribute Details

#numberObject

Returns the value of attribute number.



4
5
6
# File 'lib/changelog_generator/issue.rb', line 4

def number
  @number
end

#titleObject

Returns the value of attribute title.



3
4
5
# File 'lib/changelog_generator/issue.rb', line 3

def title
  @title
end

Class Method Details

.from_github_issue(github_issue) ⇒ Object



6
7
8
9
10
11
# File 'lib/changelog_generator/issue.rb', line 6

def self.from_github_issue(github_issue)
  self.new({
    title: github_issue['title'],
    number: github_issue['number']
  })
end

Instance Method Details

Generates a link snippet for this issue with desired text formatting Params:

user

The username of the repo owner

repo

The name of the github repository

formatting_style

The text formatting style symbol



24
25
26
27
28
29
30
31
# File 'lib/changelog_generator/issue.rb', line 24

def link_text(user, repo, formatting_style)
  if formatting_style == :slack
    return " <https://github.com/#{user}/#{repo}/issues/#{self.number}|##{self.number}>"
  elsif formatting_style == :markdown
    return " [##{self.number}](https://github.com/#{user}/#{repo}/issues/#{self.number})"
  end
  return ""
end