Class: YTools::Templates::Executor
- Inherits:
-
Object
- Object
- YTools::Templates::Executor
- Defined in:
- lib/ytools/templates/executor.rb
Instance Attribute Summary collapse
-
#template ⇒ Object
readonly
Returns the value of attribute template.
-
#yaml_object ⇒ Object
readonly
Returns the value of attribute yaml_object.
Instance Method Summary collapse
- #execute!(yaml_files, options) ⇒ Object
-
#initialize(template = nil, yaml_object = nil) ⇒ Executor
constructor
A new instance of Executor.
- #write!(outfile) ⇒ Object
Constructor Details
#initialize(template = nil, yaml_object = nil) ⇒ Executor
Returns a new instance of Executor.
9 10 11 12 |
# File 'lib/ytools/templates/executor.rb', line 9 def initialize(template=nil, yaml_object=nil) @template = template @yaml_object = yaml_object end |
Instance Attribute Details
#template ⇒ Object (readonly)
Returns the value of attribute template.
7 8 9 |
# File 'lib/ytools/templates/executor.rb', line 7 def template @template end |
#yaml_object ⇒ Object (readonly)
Returns the value of attribute yaml_object.
7 8 9 |
# File 'lib/ytools/templates/executor.rb', line 7 def yaml_object @yaml_object end |
Instance Method Details
#execute!(yaml_files, options) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ytools/templates/executor.rb', line 14 def execute!(yaml_files, ) @template = [:erb] @yaml_object = [:yaml_object] if [:debug] STDERR.puts @yaml_object.to_s end write!([:output]) end |
#write!(outfile) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ytools/templates/executor.rb', line 25 def write!(outfile) generator = ERB.new(template) output = generator.result(yaml_object.erb_binding) if outfile File.open(outfile, 'w') {|f| f.write(output)} else puts output end end |