Module: EacTemplates::Abstract::WithDirectoryFileMethods

Included in:
Modules::Ancestor, Modules::Base
Defined in:
lib/eac_templates/abstract/with_directory_file_methods.rb

Instance Method Summary collapse

Instance Method Details

#build_fs_object(type) ⇒ Object



8
9
10
# File 'lib/eac_templates/abstract/with_directory_file_methods.rb', line 8

def build_fs_object(type)
  fs_object_class(type).by_subpath(self, nil, subpath, source_set: source_set)
end

#child_subpath(child_basename) ⇒ Pathname

Parameters:

  • child_basename (Pathname)

    hild_basename [Pathname

Returns:

  • (Pathname)


14
15
16
# File 'lib/eac_templates/abstract/with_directory_file_methods.rb', line 14

def child_subpath(child_basename)
  subpath.if_present(child_basename) { |v| v.join(child_basename) }.to_pathname
end

#directoryEacTemplates::Abstract::Directory



19
20
21
# File 'lib/eac_templates/abstract/with_directory_file_methods.rb', line 19

def directory
  build_fs_object(:directory)
end

#fileEacTemplates::Abstract::File



24
25
26
# File 'lib/eac_templates/abstract/with_directory_file_methods.rb', line 24

def file
  build_fs_object(:file)
end

#fs_object_class(type) ⇒ Class

Parameters:

  • type (Symbol)

Returns:

  • (Class)


30
31
32
# File 'lib/eac_templates/abstract/with_directory_file_methods.rb', line 30

def fs_object_class(type)
  self.class.const_get(type.to_s.camelize)
end

#sub_fs_objectEacTemplates::Abstract::Directory, EacTemplates::Abstract::File



35
36
37
38
39
40
41
42
43
# File 'lib/eac_templates/abstract/with_directory_file_methods.rb', line 35

def sub_fs_object
  file_search = file
  return file_search if file_search.found?

  directory_search = directory
  return directory_search if directory_search.found?

  raise ::EacTemplates::Abstract::NotFoundError, "No template found: #{self}"
end