Class: EacTemplates::Directory
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
#initialize(path) ⇒ Directory
Returns a new instance of Directory.
11 12 13 |
# File 'lib/eac_templates/directory.rb', line 11 def initialize(path) @path = path.is_a?(::Pathname) ? path : ::Pathname.new(path.to_s) end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
9 10 11 |
# File 'lib/eac_templates/directory.rb', line 9 def path @path end |
Instance Method Details
#apply(variables_source, directory) ⇒ Object
15 16 17 |
# File 'lib/eac_templates/directory.rb', line 15 def apply(variables_source, directory) TemplateNode.new(self, '.', directory, variables_source).apply end |
#child(subpath) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/eac_templates/directory.rb', line 19 def child(subpath) child_path = ::File.join(path, subpath) return ::EacTemplates::File.new(child_path) if ::File.file?(child_path) return ::EacTemplates::Directory.new(child_path) if ::File.directory?(child_path) raise "Child \"#{subpath}\" from \"#{path}\" not found" end |
#children ⇒ Object
27 28 29 30 31 |
# File 'lib/eac_templates/directory.rb', line 27 def children path.children.map do |path_child| child(path_child.basename.to_path) end end |