Class: Pessimize::GemCollection
- Inherits:
-
Object
- Object
- Pessimize::GemCollection
- Defined in:
- lib/pessimize/gem_collection.rb
Instance Attribute Summary collapse
-
#declarations ⇒ Object
readonly
Returns the value of attribute declarations.
-
#gems ⇒ Object
readonly
Returns the value of attribute gems.
Instance Method Summary collapse
- #add_declaration(name, *args) ⇒ Object
- #add_gem(*args) ⇒ Object
- #add_grouped_gem(group, *args) ⇒ Object
- #all ⇒ Object
-
#initialize ⇒ GemCollection
constructor
A new instance of GemCollection.
Constructor Details
#initialize ⇒ GemCollection
Returns a new instance of GemCollection.
8 9 10 11 12 13 |
# File 'lib/pessimize/gem_collection.rb', line 8 def initialize @gems = Hash.new do |hash, missing| hash[missing] = [] end @declarations = [] end |
Instance Attribute Details
#declarations ⇒ Object
Returns the value of attribute declarations.
6 7 8 |
# File 'lib/pessimize/gem_collection.rb', line 6 def declarations @declarations end |
#gems ⇒ Object
Returns the value of attribute gems.
6 7 8 |
# File 'lib/pessimize/gem_collection.rb', line 6 def gems @gems end |
Instance Method Details
#add_declaration(name, *args) ⇒ Object
23 24 25 |
# File 'lib/pessimize/gem_collection.rb', line 23 def add_declaration(name, *args) self.declarations << Declaration.new(name, *args) end |
#add_gem(*args) ⇒ Object
15 16 17 |
# File 'lib/pessimize/gem_collection.rb', line 15 def add_gem(*args) add_grouped_gem(:global, *args) end |
#add_grouped_gem(group, *args) ⇒ Object
19 20 21 |
# File 'lib/pessimize/gem_collection.rb', line 19 def add_grouped_gem(group, *args) self.gems[group] << Gem.new(*args) end |
#all ⇒ Object
27 28 29 |
# File 'lib/pessimize/gem_collection.rb', line 27 def all gems.values.flatten end |