Class: TagChangelog::MessageList
- Inherits:
-
Object
- Object
- TagChangelog::MessageList
- Defined in:
- lib/tag_changelog/message_list.rb
Instance Attribute Summary collapse
-
#grouped ⇒ Object
readonly
Returns the value of attribute grouped.
-
#messages ⇒ Object
readonly
Returns the value of attribute messages.
Instance Method Summary collapse
-
#initialize(messages = [], grouped = true) ⇒ MessageList
constructor
A new instance of MessageList.
- #print_category(category) ⇒ Object
- #print_lines(lines) ⇒ Object
- #to_text ⇒ Object
Constructor Details
#initialize(messages = [], grouped = true) ⇒ MessageList
Returns a new instance of MessageList.
5 6 7 8 |
# File 'lib/tag_changelog/message_list.rb', line 5 def initialize( = [], grouped = true) = @grouped = grouped end |
Instance Attribute Details
#grouped ⇒ Object (readonly)
Returns the value of attribute grouped.
3 4 5 |
# File 'lib/tag_changelog/message_list.rb', line 3 def grouped @grouped end |
#messages ⇒ Object (readonly)
Returns the value of attribute messages.
3 4 5 |
# File 'lib/tag_changelog/message_list.rb', line 3 def end |
Instance Method Details
#print_category(category) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/tag_changelog/message_list.rb', line 20 def print_category(category) [ "#### #{category['header']}", print_lines(category["messages"]).join(""), ].join("\n") end |
#print_lines(lines) ⇒ Object
27 28 29 |
# File 'lib/tag_changelog/message_list.rb', line 27 def print_lines(lines) lines.map { |line| "* #{line}\n" } end |
#to_text ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/tag_changelog/message_list.rb', line 10 def to_text if grouped .map do |category| category["messages"].any? ? print_category(category) : nil end.reject(&:nil?).join("") else print_lines().reject(&:nil?).join("") end end |