Class: DotfileGroup
- Inherits:
-
Object
- Object
- DotfileGroup
- Defined in:
- lib/polka/dotfile_group.rb
Constant Summary collapse
- @@all_files =
[]
- @@grouped_files =
[]
- @@all_other_files_added =
false
Class Method Summary collapse
Instance Method Summary collapse
- #add(new_files) ⇒ Object
- #add_all_other_files ⇒ Object
- #files ⇒ Object
-
#initialize(operation = nil, setup_msg = nil) ⇒ DotfileGroup
constructor
A new instance of DotfileGroup.
- #setup ⇒ Object
Constructor Details
#initialize(operation = nil, setup_msg = nil) ⇒ DotfileGroup
Returns a new instance of DotfileGroup.
19 20 21 22 23 24 |
# File 'lib/polka/dotfile_group.rb', line 19 def initialize(operation=nil, setup_msg=nil) @operation = operation @setup_message = setup_msg @files = [] @all_other_files = false end |
Class Method Details
.all_files=(files) ⇒ Object
9 10 11 12 13 |
# File 'lib/polka/dotfile_group.rb', line 9 def self.all_files=(files) @@all_files = files @@grouped_files = [] @@all_other_files_added = false end |
.remaining_files ⇒ Object
15 16 17 |
# File 'lib/polka/dotfile_group.rb', line 15 def self.remaining_files @@all_files - @@grouped_files end |
Instance Method Details
#add(new_files) ⇒ Object
26 27 28 29 30 |
# File 'lib/polka/dotfile_group.rb', line 26 def add(new_files) raise FileAlreadyAddedError if new_files.any? { |f| @@grouped_files.include?(f) } @@grouped_files += new_files @files += new_files end |
#add_all_other_files ⇒ Object
32 33 34 35 36 |
# File 'lib/polka/dotfile_group.rb', line 32 def add_all_other_files raise AllOtherFilesAlreadyAdded if @@all_other_files_added @@all_other_files_added = true @all_other_files = true end |
#files ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/polka/dotfile_group.rb', line 38 def files if @all_other_files DotfileGroup.remaining_files + @files else @files end end |