Class: EacRubyUtils::Templates::Directory
- Defined in:
- lib/eac_ruby_utils/templates/directory.rb
Defined Under Namespace
Classes: TemplateNode
Constant Summary collapse
- TEMPLATE_EXTNAME =
'.template'
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #apply(variables_source, directory) ⇒ Object
- #child(subpath) ⇒ Object
- #children ⇒ Object
-
#initialize(path) ⇒ Directory
constructor
A new instance of Directory.
Constructor Details
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
10 11 12 |
# File 'lib/eac_ruby_utils/templates/directory.rb', line 10 def path @path end |
Instance Method Details
#apply(variables_source, directory) ⇒ Object
16 17 18 |
# File 'lib/eac_ruby_utils/templates/directory.rb', line 16 def apply(variables_source, directory) TemplateNode.new(self, '.', directory, variables_source).apply end |
#child(subpath) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/eac_ruby_utils/templates/directory.rb', line 20 def child(subpath) child_path = ::File.join(path, subpath) return ::EacRubyUtils::Templates::File.new(child_path) if ::File.file?(child_path) return ::EacRubyUtils::Templates::Directory.new(child_path) if ::File.directory?(child_path) raise "Child \"#{subpath}\" from \"#{path}\" not found" end |
#children ⇒ Object
28 29 30 31 32 |
# File 'lib/eac_ruby_utils/templates/directory.rb', line 28 def children path.children.map do |path_child| child(path_child.basename.to_path) end end |