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
- #build_fs_object(type) ⇒ Object
- #child_subpath(child_basename) ⇒ Pathname
- #directory? ⇒ Boolean
- #file? ⇒ Boolean
- #file_template? ⇒ Boolean
- #found? ⇒ Boolean
- #fs_object_class(type) ⇒ Class
- #sub_fs_object ⇒ EacTemplates::Abstract::Directory, EacTemplates::Abstract::File
- #to_s ⇒ String
Instance Method Details
#build_fs_object(type) ⇒ Object
10 11 12 |
# File 'lib/eac_templates/abstract/with_directory_file_methods.rb', line 10 def build_fs_object(type) fs_object_class(type).by_subpath(self, nil, subpath, source_set: source_set) end |
#child_subpath(child_basename) ⇒ Pathname
16 17 18 |
# File 'lib/eac_templates/abstract/with_directory_file_methods.rb', line 16 def child_subpath(child_basename) subpath.if_present(child_basename) { |v| v.join(child_basename) }.to_pathname end |
#directory? ⇒ Boolean
21 22 23 |
# File 'lib/eac_templates/abstract/with_directory_file_methods.rb', line 21 def directory? directory.found? end |
#file? ⇒ Boolean
26 27 28 |
# File 'lib/eac_templates/abstract/with_directory_file_methods.rb', line 26 def file? file.found? end |
#file_template? ⇒ Boolean
31 32 33 |
# File 'lib/eac_templates/abstract/with_directory_file_methods.rb', line 31 def file_template? file? && file.template? end |
#found? ⇒ Boolean
36 37 38 |
# File 'lib/eac_templates/abstract/with_directory_file_methods.rb', line 36 def found? directory? || file? end |
#fs_object_class(type) ⇒ Class
42 43 44 |
# File 'lib/eac_templates/abstract/with_directory_file_methods.rb', line 42 def fs_object_class(type) self.class.const_get(type.to_s.camelize) end |
#sub_fs_object ⇒ EacTemplates::Abstract::Directory, EacTemplates::Abstract::File
47 48 49 50 51 52 |
# File 'lib/eac_templates/abstract/with_directory_file_methods.rb', line 47 def sub_fs_object return file if file.found? return directory if directory.found? raise ::EacTemplates::Errors::NotFound, "No template found: #{self}" end |
#to_s ⇒ String
55 56 57 58 59 60 |
# File 'lib/eac_templates/abstract/with_directory_file_methods.rb', line 55 def to_s v = 'NOT_FOUND' v = directory.to_s if directory? v = file.to_s if file? "#{self.class.name}[#{v}]" end |