Class: EacTemplates::Modules::Base
- Inherits:
-
Object
- Object
- EacTemplates::Modules::Base
show all
- Includes:
- Abstract::WithDirectoryFileMethods
- Defined in:
- lib/eac_templates/modules/base.rb,
lib/eac_templates/modules/base/file.rb,
lib/eac_templates/modules/base/directory.rb,
lib/eac_templates/modules/base/fs_object.rb
Defined Under Namespace
Modules: FsObject
Classes: Directory, File
Instance Method Summary
collapse
#build_fs_object, #child_subpath, #directory?, #file?, #file_template?, #fs_object_class, #sub_fs_object
Instance Method Details
28
29
30
31
32
33
34
35
36
|
# File 'lib/eac_templates/modules/base.rb', line 28
def build_child(child_basename, child_type)
r = ::EacTemplates::Modules::Base.new(
the_module, subpath: child_subpath(child_basename), source_set: source_set
)
return r.validate_type(child_type) if r.found?
raise ::EacTemplates::Errors::NotFound,
"No child for #{self} found with basename \"#{child_basename}\""
end
|
#found? ⇒ Boolean
39
40
41
|
# File 'lib/eac_templates/modules/base.rb', line 39
def found?
file.found? || directory.found?
end
|
#source_set ⇒ EacTemplates::SourceSet
44
45
46
|
# File 'lib/eac_templates/modules/base.rb', line 44
def source_set
options[OPTION_SOURCE_SET] || ::EacTemplates::Sources::Set.default
end
|
#subpath ⇒ Pathname?
49
50
51
|
# File 'lib/eac_templates/modules/base.rb', line 49
def subpath
options[OPTION_SUBPATH].if_present(&:to_pathname)
end
|
#to_s ⇒ String
54
55
56
|
# File 'lib/eac_templates/modules/base.rb', line 54
def to_s
"#{self.class}[#{the_module.name}#\"#{subpath}\"]"
end
|
#validate_type(required_type) ⇒ self
61
62
63
64
65
66
|
# File 'lib/eac_templates/modules/base.rb', line 61
def validate_type(required_type)
return self if valid_type?(required_type)
raise ::EacTemplates::Errors::TypeMismatch, "A #{required_type} type was expected, but a " \
"#{type} was builded"
end
|