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



12
13
14
# File 'lib/eac_templates/abstract/with_directory_file_methods.rb', line 12

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)


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

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

#directory?Boolean

Returns:

  • (Boolean)


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

def directory?
  directory.found?
end

#file?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/eac_templates/abstract/with_directory_file_methods.rb', line 28

def file?
  file.found?
end

#file_template?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/eac_templates/abstract/with_directory_file_methods.rb', line 33

def file_template?
  file? && file.template?
end

#found?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/eac_templates/abstract/with_directory_file_methods.rb', line 38

def found?
  directory? || file?
end

#fs_object_class(type) ⇒ Class

Parameters:

  • type (Symbol)

Returns:

  • (Class)


44
45
46
# File 'lib/eac_templates/abstract/with_directory_file_methods.rb', line 44

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

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



49
50
51
52
53
54
# File 'lib/eac_templates/abstract/with_directory_file_methods.rb', line 49

def sub_fs_object
  return file if file.found?
  return directory if directory.found?

  raise ::EacTemplates::Errors::NotFound, "No template found: #{self}"
end

#to_sString

Returns:

  • (String)


57
58
59
60
61
62
# File 'lib/eac_templates/abstract/with_directory_file_methods.rb', line 57

def to_s
  v = 'NOT_FOUND'
  v = directory.to_s if directory?
  v = file.to_s if file?
  "#{self.class.name}[#{v}]"
end