Class: Gemfiler::Filer
- Inherits:
-
Object
- Object
- Gemfiler::Filer
- Defined in:
- lib/Gemfiler/filer.rb
Instance Attribute Summary collapse
-
#cabinet ⇒ Object
Returns the value of attribute cabinet.
-
#groups ⇒ Object
Returns the value of attribute groups.
-
#uncategorized ⇒ Object
Returns the value of attribute uncategorized.
Instance Method Summary collapse
- #alphabetize ⇒ Object
- #group ⇒ Object
-
#initialize(cabinet) ⇒ Filer
constructor
A new instance of Filer.
-
#shim ⇒ Object
Delegate shim.
Constructor Details
#initialize(cabinet) ⇒ Filer
Returns a new instance of Filer.
5 6 7 8 9 |
# File 'lib/Gemfiler/filer.rb', line 5 def initialize(cabinet) @cabinet = cabinet @groups = {} @uncategorized = [] end |
Instance Attribute Details
#cabinet ⇒ Object
Returns the value of attribute cabinet.
3 4 5 |
# File 'lib/Gemfiler/filer.rb', line 3 def cabinet @cabinet end |
#groups ⇒ Object
Returns the value of attribute groups.
3 4 5 |
# File 'lib/Gemfiler/filer.rb', line 3 def groups @groups end |
#uncategorized ⇒ Object
Returns the value of attribute uncategorized.
3 4 5 |
# File 'lib/Gemfiler/filer.rb', line 3 def uncategorized @uncategorized end |
Instance Method Details
#alphabetize ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/Gemfiler/filer.rb', line 23 def alphabetize self.uncategorized = alphabetize_from_array(self.uncategorized) self.groups = self.groups.inject({}) do |hash, (groups, gems)| hash[groups] = alphabetize_from_array(gems) hash end end |
#group ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/Gemfiler/filer.rb', line 11 def group cabinet.gems.each do |gem| if gem[:groups] gem_groups = gem.delete(:groups).sort groups[gem_groups] ||= [] groups[gem_groups] << gem else uncategorized << gem end end end |
#shim ⇒ Object
Delegate shim
32 33 34 |
# File 'lib/Gemfiler/filer.rb', line 32 def shim cabinet.shim end |