Class: Yarnlock::Entry::Collection
- Inherits:
-
Hash
- Object
- Hash
- Yarnlock::Entry::Collection
- Defined in:
- lib/yarnlock/entry/collection.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.parse(raw_entries) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/yarnlock/entry/collection.rb', line 6 def self.parse(raw_entries) collection = new raw_entries.each do |pattern, raw_entry| entry = Yarnlock::Entry.parse pattern, raw_entry collection[entry.package] ||= {} collection[entry.package][entry.version] = entry end collection end |
Instance Method Details
#as_json(_options = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/yarnlock/entry/collection.rb', line 16 def as_json( = {}) entries = {} each_value do |versions| versions.each_value do |entry| entries.merge! entry.to_h end end entries end |
#to_json(*options) ⇒ Object
26 27 28 |
# File 'lib/yarnlock/entry/collection.rb', line 26 def to_json(*) as_json(*).to_json(*) end |