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
29
30
31
32
33
34
35
36
37
|
# File 'lib/eac_templates/modules/base.rb', line 29
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
40
41
42
|
# File 'lib/eac_templates/modules/base.rb', line 40
def found?
file.found? || directory.found?
end
|
#source_set ⇒ EacTemplates::SourceSet
45
46
47
|
# File 'lib/eac_templates/modules/base.rb', line 45
def source_set
options[OPTION_SOURCE_SET] || ::EacTemplates::Sources::Set.default
end
|
#subpath ⇒ Pathname?
50
51
52
|
# File 'lib/eac_templates/modules/base.rb', line 50
def subpath
options[OPTION_SUBPATH].if_present(&:to_pathname)
end
|
#to_s ⇒ String
55
56
57
|
# File 'lib/eac_templates/modules/base.rb', line 55
def to_s
"#{self.class}[#{the_module.name}#\"#{subpath}\"]"
end
|
#validate_type(required_type) ⇒ self
62
63
64
65
66
67
|
# File 'lib/eac_templates/modules/base.rb', line 62
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
|