Class: RGen::TemplateLanguage::DirectoryTemplateContainer
- Inherits:
-
Object
- Object
- RGen::TemplateLanguage::DirectoryTemplateContainer
- Includes:
- TemplateHelper
- Defined in:
- lib/rgen/template_language/directory_template_container.rb
Instance Method Summary collapse
- #expand(template, *all_args) ⇒ Object
- #indentString ⇒ Object
-
#indentString=(str) ⇒ Object
Set indentation string.
-
#initialize(metamodel = nil, output_path = nil, parent = nil) ⇒ DirectoryTemplateContainer
constructor
A new instance of DirectoryTemplateContainer.
- #load(dir) ⇒ Object
Constructor Details
#initialize(metamodel = nil, output_path = nil, parent = nil) ⇒ DirectoryTemplateContainer
Returns a new instance of DirectoryTemplateContainer.
14 15 16 17 18 19 20 |
# File 'lib/rgen/template_language/directory_template_container.rb', line 14 def initialize(=nil, output_path=nil, parent=nil) @containers = {} @directoryContainers = {} @parent = parent @metamodel = @output_path = output_path end |
Instance Method Details
#expand(template, *all_args) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rgen/template_language/directory_template_container.rb', line 33 def (template, *all_args) if template =~ /^\// if @parent # pass to parent @parent.(template, *all_args) else # this is root (template, *all_args) end elsif template =~ /^\.\.\/(.*)/ if @parent # pass to parent @parent.($1, *all_args) else raise "No parent directory for root" end else (template, *all_args) end end |
#indentString ⇒ Object
61 62 63 |
# File 'lib/rgen/template_language/directory_template_container.rb', line 61 def indentString @indentString || (@parent && @parent.indentString) || " " end |
#indentString=(str) ⇒ Object
Set indentation string. Every generated line will be prependend with n times this string at an indentation level of n. Defaults to “ ” (3 spaces)
57 58 59 |
# File 'lib/rgen/template_language/directory_template_container.rb', line 57 def indentString=(str) @indentString = str end |
#load(dir) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rgen/template_language/directory_template_container.rb', line 22 def load(dir) Dir.foreach(dir) { |f| qf = dir+"/"+f if !File.directory?(qf) && f =~ /^(.*)\.tpl$/ (@containers[$1] = TemplateContainer.new(@metamodel, @output_path, self,qf)).load elsif File.directory?(qf) && f != "." && f != ".." (@directoryContainers[f] = DirectoryTemplateContainer.new(@metamodel, @output_path, self)).load(qf) end } end |