Class: Dotify::Collection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/dotify/collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(location = :dotfiles) ⇒ Collection

Pulls an array of Dots from the home directory.



10
11
12
13
14
15
16
17
# File 'lib/dotify/collection.rb', line 10

def initialize(location = :dotfiles)
  @dots ||= case location
            when :dotfiles then Filter.home
            when :dotify then Filter.dotify
            else
              raise ArgumentError, "You must specify :dotfiles or :dotify when initializing Collection"
            end
end

Instance Attribute Details

#dotsObject

Returns the value of attribute dots.



6
7
8
# File 'lib/dotify/collection.rb', line 6

def dots
  @dots
end

Instance Method Details

#each(&block) ⇒ Object

Defined each method for Enumerable



20
21
22
# File 'lib/dotify/collection.rb', line 20

def each(&block)
  dots.each(&block)
end

#inspectObject



41
42
43
# File 'lib/dotify/collection.rb', line 41

def inspect
  dots.map(&:inspect)
end

#linkedObject

Linked files are those files which have a symbolic link pointing to the Dotify file.



26
27
28
# File 'lib/dotify/collection.rb', line 26

def linked
  select(&:linked?)
end

#to_sObject



37
38
39
# File 'lib/dotify/collection.rb', line 37

def to_s
  dots.to_s
end

#unlinkedObject

Unlinked files are, of course, the opposite of linked files. These are Dotify files which Have no home dir files that are linked to them.



33
34
35
# File 'lib/dotify/collection.rb', line 33

def unlinked
  reject(&:linked?)
end