Class: Bundler::Alive::StatusCollection
- Inherits:
-
Object
- Object
- Bundler::Alive::StatusCollection
- Extended by:
- Forwardable
- Defined in:
- lib/bundler/alive/status_collection.rb
Overview
Collection of Status
Instance Attribute Summary collapse
-
#alive_size ⇒ Object
readonly
Returns the value of attribute alive_size.
-
#archived_size ⇒ Object
readonly
Returns the value of attribute archived_size.
-
#unknown_size ⇒ Object
readonly
Returns the value of attribute unknown_size.
Instance Method Summary collapse
-
#[](name) ⇒ Status
Fetch
Status
ofname
. -
#add(name, status) ⇒ StatusCollection
Add status.
-
#all_alive? ⇒ Boolean
All of statuses are alive nor not.
- #archived_gems ⇒ Object
-
#initialize(collection = {}) ⇒ StatusCollection
constructor
Generates instance of
StatusCollection
. -
#merge(collection) ⇒ StatusCollection
Merge collection.
-
#names ⇒ Array<String>
Names of gems.
- #to_h ⇒ Object
-
#total_size ⇒ Integer
Total size of collection.
- #unknown_gems ⇒ Object
Constructor Details
#initialize(collection = {}) ⇒ StatusCollection
Generates instance of StatusCollection
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/bundler/alive/status_collection.rb', line 22 def initialize(collection = {}) @collection = collection @statuses_values = collection.values || [] @alive_size = _alive_size @unknown_size = _unknown_size @archived_size = _archived_size freeze end |
Instance Attribute Details
#alive_size ⇒ Object (readonly)
Returns the value of attribute alive_size.
13 14 15 |
# File 'lib/bundler/alive/status_collection.rb', line 13 def alive_size @alive_size end |
#archived_size ⇒ Object (readonly)
Returns the value of attribute archived_size.
13 14 15 |
# File 'lib/bundler/alive/status_collection.rb', line 13 def archived_size @archived_size end |
#unknown_size ⇒ Object (readonly)
Returns the value of attribute unknown_size.
13 14 15 |
# File 'lib/bundler/alive/status_collection.rb', line 13 def unknown_size @unknown_size end |
Instance Method Details
#[](name) ⇒ Status
Fetch Status
of name
40 41 42 |
# File 'lib/bundler/alive/status_collection.rb', line 40 def [](name) collection[name] end |
#add(name, status) ⇒ StatusCollection
Add status
61 62 63 64 65 |
# File 'lib/bundler/alive/status_collection.rb', line 61 def add(name, status) collection[name] = status self.class.new(collection) end |
#all_alive? ⇒ Boolean
All of statuses are alive nor not
101 102 103 |
# File 'lib/bundler/alive/status_collection.rb', line 101 def all_alive? collection.find { |_name, status| !!!status.alive || status.unknown? }.nil? end |
#archived_gems ⇒ Object
88 89 90 |
# File 'lib/bundler/alive/status_collection.rb', line 88 def archived_gems collection.find_all { |_name, gem| !!!gem.alive } end |
#merge(collection) ⇒ StatusCollection
Merge collection
74 75 76 77 78 79 80 81 82 |
# File 'lib/bundler/alive/status_collection.rb', line 74 def merge(collection) return self.class.new(self.collection) if collection.nil? collection.each do |k, v| self.collection[k] = v end self.class.new(self.collection) end |
#names ⇒ Array<String>
Names of gems
49 50 51 |
# File 'lib/bundler/alive/status_collection.rb', line 49 def names values.map(&:name) end |
#to_h ⇒ Object
84 85 86 |
# File 'lib/bundler/alive/status_collection.rb', line 84 def to_h collection.transform_values(&:to_h) end |
#total_size ⇒ Integer
Total size of collection
110 111 112 |
# File 'lib/bundler/alive/status_collection.rb', line 110 def total_size collection.size end |
#unknown_gems ⇒ Object
92 93 94 |
# File 'lib/bundler/alive/status_collection.rb', line 92 def unknown_gems collection.find_all { |_name, gem| gem.unknown? } end |