Class: Renogen::ChangeLog::Model
- Inherits:
-
Object
- Object
- Renogen::ChangeLog::Model
- Defined in:
- lib/renogen/change_log/model.rb
Overview
Object to represent a Changelog/release notes
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
-
#add_change(change) ⇒ Array
Adds a change to the changelog.
- #groups ⇒ Hash<group_name: change>
-
#initialize(options = {}) ⇒ Model
constructor
A new instance of Model.
- #tickets ⇒ Hash<ticket id: string>
Constructor Details
#initialize(options = {}) ⇒ Model
Returns a new instance of Model.
10 11 12 13 14 |
# File 'lib/renogen/change_log/model.rb', line 10 def initialize(={}) @version = [:version] @date = [:date] || Date.today @items = [] end |
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date.
8 9 10 |
# File 'lib/renogen/change_log/model.rb', line 8 def date @date end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
7 8 9 |
# File 'lib/renogen/change_log/model.rb', line 7 def items @items end |
#version ⇒ Object
Returns the value of attribute version.
8 9 10 |
# File 'lib/renogen/change_log/model.rb', line 8 def version @version end |
Instance Method Details
#add_change(change) ⇒ Array
Adds a change to the changelog
38 39 40 41 |
# File 'lib/renogen/change_log/model.rb', line 38 def add_change(change) raise TypeError unless change.is_a?(Renogen::ChangeLog::Item) items << change end |
#groups ⇒ Hash<group_name: change>
17 18 19 20 21 22 23 |
# File 'lib/renogen/change_log/model.rb', line 17 def groups items.inject({}) do |hash, change| hash[change.group_name] ||= [] hash[change.group_name] << change hash end end |
#tickets ⇒ Hash<ticket id: string>
26 27 28 29 30 31 32 |
# File 'lib/renogen/change_log/model.rb', line 26 def tickets items.inject({}) do |hash, change| hash[change.ticket_id] ||= {} hash[change.ticket_id][change.group_name] = change.to_s hash end end |