Class: PrChangelog::GroupedChanges
- Inherits:
-
Object
- Object
- PrChangelog::GroupedChanges
- Defined in:
- lib/pr_changelog/grouped_changes.rb
Overview
A class to group change lines by tag
Instance Attribute Summary collapse
-
#changes ⇒ Object
readonly
Returns the value of attribute changes.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Instance Method Summary collapse
-
#initialize(changes, tags) ⇒ GroupedChanges
constructor
A new instance of GroupedChanges.
- #to_s ⇒ Object
Constructor Details
#initialize(changes, tags) ⇒ GroupedChanges
Returns a new instance of GroupedChanges.
8 9 10 11 |
# File 'lib/pr_changelog/grouped_changes.rb', line 8 def initialize(changes, ) @changes = changes @tags = end |
Instance Attribute Details
#changes ⇒ Object (readonly)
Returns the value of attribute changes.
6 7 8 |
# File 'lib/pr_changelog/grouped_changes.rb', line 6 def changes @changes end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
6 7 8 |
# File 'lib/pr_changelog/grouped_changes.rb', line 6 def @tags end |
Instance Method Details
#to_s ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/pr_changelog/grouped_changes.rb', line 13 def to_s new_hash = {} grouped_changes.each do |tag, change_lines| new_key = tag.formatted_title new_hash[new_key] = change_lines.map do |change_line| change_line.emojified_for(tag) end end new_hash.reduce('') do |string, pair| tag = pair[0] lines = pair[1].map { |l| " #{l}" }.join("\n") string + "#{tag}\n#{lines}\n\n" end.strip.chomp end |