Class: EacTemplates::Abstract::Directory

Inherits:
FsObject show all
Defined in:
lib/eac_templates/abstract/directory.rb

Instance Method Summary collapse

Methods inherited from FsObject

#applier, #applier_class, assert, by_subpath, #category_module, #path_for_search, #path_for_search_prefix, #raise_not_found, #source_set, #type, #type_list

Instance Method Details

#build_child(child_basename, child_type) ⇒ EacTemplates::Abstract::FsObject

Parameters:

  • basename (Pathname)

Returns:



16
17
18
19
20
21
# File 'lib/eac_templates/abstract/directory.rb', line 16

def build_child(child_basename, child_type)
  child_basename = child_basename.to_pathname
  child_type = type_list.value_validate!(child_type)
  category_module.const_get(child_type.to_s.camelize)
    .new(owner, self, child_basename, options)
end

#child(basename) ⇒ EacTemplates::Abstract::FsObject

Parameters:

  • basename (Pathname)

Returns:



25
26
27
28
29
# File 'lib/eac_templates/abstract/directory.rb', line 25

def child(basename)
  basename = basename.to_pathname
  children.find { |c| c.basename == basename } ||
    raise_not_found("No child found with basename \"#{basename}\"")
end

#childrenEnumerable<EacTemplates::Abstract::FsObject>

Returns:



32
33
34
# File 'lib/eac_templates/abstract/directory.rb', line 32

def children
  children_basenames.map { |c_basename, c_type| build_child(c_basename, c_type) }
end

#children_basenamesHash<Pathname, Symbol>

Returns:

  • (Hash<Pathname, Symbol>)


37
38
39
# File 'lib/eac_templates/abstract/directory.rb', line 37

def children_basenames
  raise_abstract_method __method__
end