Class: Stepmod::Utils::ChangeEditionCollection
- Inherits:
-
Object
- Object
- Stepmod::Utils::ChangeEditionCollection
- Defined in:
- lib/stepmod/utils/change_edition_collection.rb
Instance Method Summary collapse
- #[](version) ⇒ Object
- #[]=(version, change_edition) ⇒ Object
- #count ⇒ Object (also: #size)
- #fetch_or_initialize(version) ⇒ Object
-
#initialize ⇒ ChangeEditionCollection
constructor
A new instance of ChangeEditionCollection.
- #to_h ⇒ Object
Constructor Details
#initialize ⇒ ChangeEditionCollection
Returns a new instance of ChangeEditionCollection.
6 7 8 |
# File 'lib/stepmod/utils/change_edition_collection.rb', line 6 def initialize @collection = {} end |
Instance Method Details
#[](version) ⇒ Object
28 29 30 |
# File 'lib/stepmod/utils/change_edition_collection.rb', line 28 def [](version) @collection[version] end |
#[]=(version, change_edition) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/stepmod/utils/change_edition_collection.rb', line 19 def []=(version, change_edition) klass = Stepmod::Utils::ChangeEdition @collection[version] = if change_edition.is_a?(klass) change_edition else klass.new(change_edition) end end |
#count ⇒ Object Also known as: size
32 33 34 |
# File 'lib/stepmod/utils/change_edition_collection.rb', line 32 def count @collection.values.count end |
#fetch_or_initialize(version) ⇒ Object
10 11 12 13 |
# File 'lib/stepmod/utils/change_edition_collection.rb', line 10 def fetch_or_initialize(version) @collection[version] ||= Stepmod::Utils::ChangeEdition.new(version: version) end |
#to_h ⇒ Object
15 16 17 |
# File 'lib/stepmod/utils/change_edition_collection.rb', line 15 def to_h @collection.values.map(&:to_h) end |