Class: EacTemplates::Variables::Directory

Inherits:
Object
  • Object
show all
Defined in:
lib/eac_templates/variables/directory.rb

Instance Method Summary collapse

Instance Method Details

#apply(variables_source, directory) ⇒ Object



16
17
18
# File 'lib/eac_templates/variables/directory.rb', line 16

def apply(variables_source, directory)
  ::EacTemplates::Variables::FsObject.new(self, '.', directory, variables_source).apply
end

#child(subpath) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/eac_templates/variables/directory.rb', line 20

def child(subpath)
  child_path = ::File.join(path, subpath)
  return ::EacTemplates::Variables::File.new(child_path) if ::File.file?(child_path)
  return ::EacTemplates::Variables::Directory.new(child_path) if ::File.directory?(child_path)

  raise ::EacTemplates::Abstract::NotFoundError,
        "Child \"#{subpath}\" from \"#{path}\" not found"
end

#childrenObject



29
30
31
32
33
# File 'lib/eac_templates/variables/directory.rb', line 29

def children
  path.children.map do |path_child|
    child(path_child.basename.to_path)
  end
end