Class: EacTemplates::Sources::Set

Inherits:
Object
  • Object
show all
Defined in:
lib/eac_templates/sources/set.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.defaultObject



13
14
15
# File 'lib/eac_templates/sources/set.rb', line 13

def default
  @default ||= new
end

Instance Method Details

#directory(subpath) ⇒ EacTemplates::Sources::Directory

Parameters:

  • subpath (Pathname)

Returns:



20
21
22
# File 'lib/eac_templates/sources/set.rb', line 20

def directory(subpath)
  ::EacTemplates::Sources::Directory.by_subpath(self, nil, subpath, source_set: self)
end

#file(subpath) ⇒ EacTemplates::Sources::Directory

Parameters:

  • subpath (Pathname)

Returns:



26
27
28
# File 'lib/eac_templates/sources/set.rb', line 26

def file(subpath)
  ::EacTemplates::Sources::File.by_subpath(self, nil, subpath, source_set: self)
end

#included_pathsEacTemplates::Sources::InternalSet



43
44
45
# File 'lib/eac_templates/sources/set.rb', line 43

def included_paths
  @included_paths ||= ::EacTemplates::Sources::InternalSet.new
end

#template(subpath, required = true) ⇒ Object

rubocop:disable Style/OptionalBooleanParameter



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/eac_templates/sources/set.rb', line 30

def template(subpath, required = true) # rubocop:disable Style/OptionalBooleanParameter
  found_file = file(subpath)
  return found_file if found_file.found?

  found_directory = directory(subpath)
  return found_directory if found_directory.found?

  return nil unless required

  raise_template_not_found(subpath)
end

#to_sString

Returns:

  • (String)


48
49
50
# File 'lib/eac_templates/sources/set.rb', line 48

def to_s
  "#{self.class.name}[#{included_paths}]"
end