Class: ChefFS::FileSystem::CookbookSubdir

Inherits:
BaseFSDir show all
Defined in:
lib/chef_fs/file_system/cookbook_subdir.rb

Instance Attribute Summary collapse

Attributes inherited from BaseFSObject

#name, #parent, #path

Instance Method Summary collapse

Methods inherited from BaseFSDir

#child, #dir?

Methods inherited from BaseFSObject

#chef_object, #child, #compare_to, #create_child, #delete, #dir?, #exists?, #path_for_printing, #read, #root, #write

Constructor Details

#initialize(name, parent, ruby_only, recursive) ⇒ CookbookSubdir

Returns a new instance of CookbookSubdir.



24
25
26
27
28
29
# File 'lib/chef_fs/file_system/cookbook_subdir.rb', line 24

def initialize(name, parent, ruby_only, recursive)
  super(name, parent)
  @children = []
  @ruby_only = ruby_only
  @recursive = recursive
end

Instance Attribute Details

#childrenObject (readonly)

Returns the value of attribute children.



32
33
34
# File 'lib/chef_fs/file_system/cookbook_subdir.rb', line 32

def children
  @children
end

#versionsObject (readonly)

Returns the value of attribute versions.



31
32
33
# File 'lib/chef_fs/file_system/cookbook_subdir.rb', line 31

def versions
  @versions
end

Instance Method Details

#add_child(child) ⇒ Object



34
35
36
# File 'lib/chef_fs/file_system/cookbook_subdir.rb', line 34

def add_child(child)
  @children << child
end

#can_have_child?(name, is_dir) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
41
42
43
44
45
# File 'lib/chef_fs/file_system/cookbook_subdir.rb', line 38

def can_have_child?(name, is_dir)
  if is_dir
    return false if !@recursive
  else
    return false if @ruby_only && name !~ /\.rb$/
  end
  true
end

#restObject



47
48
49
# File 'lib/chef_fs/file_system/cookbook_subdir.rb', line 47

def rest
  parent.rest
end