Class: Chef::ChefFS::FileSystem::CookbookSubdir

Inherits:
BaseFSDir show all
Defined in:
lib/chef/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

#child, #compare_to, #dir?, #exists?, #path_for_printing, #root

Constructor Details

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

Returns a new instance of CookbookSubdir.



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

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.



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

def children
  @children
end

#versionsObject (readonly)

Returns the value of attribute versions.



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

def versions
  @versions
end

Instance Method Details

#add_child(child) ⇒ Object



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

def add_child(child)
  @children << child
end

#can_have_child?(name, is_dir) ⇒ Boolean

Returns:

  • (Boolean)


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

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



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

def rest
  parent.rest
end