Class: TreeRenderer
- Inherits:
-
Object
- Object
- TreeRenderer
- Defined in:
- lib/tree_renderer.rb,
lib/tree_renderer/version.rb
Overview
Render a tree of files using ERB
example:
TreeRenderer.new("/template/path", "/target/path", variables).save
Constant Summary collapse
- VERSION =
Version of the gem
"1.1.0"
Instance Attribute Summary collapse
-
#target_path ⇒ String
readonly
The target path where to render the template.
-
#template_path ⇒ String
readonly
The path to the template directory to be rendered.
-
#var_binding ⇒ Binding
readonly
Binding for the variables to use for rendering.
Instance Method Summary collapse
-
#initialize(template_path, target_path, variables = {}) ⇒ TreeRenderer
constructor
Initialize the paths and variables for rendering.
-
#save ⇒ Object
Run the rendering process.
Constructor Details
#initialize(template_path, target_path, variables = {}) ⇒ TreeRenderer
Initialize the paths and variables for rendering
31 32 33 34 35 |
# File 'lib/tree_renderer.rb', line 31 def initialize(template_path, target_path, variables = {}) @template_path = template_path @target_path = target_path @var_binding = calculate_binding(variables) end |
Instance Attribute Details
#target_path ⇒ String (readonly)
Returns the target path where to render the template.
21 22 23 |
# File 'lib/tree_renderer.rb', line 21 def target_path @target_path end |
#template_path ⇒ String (readonly)
Returns the path to the template directory to be rendered.
19 20 21 |
# File 'lib/tree_renderer.rb', line 19 def template_path @template_path end |
#var_binding ⇒ Binding (readonly)
Returns binding for the variables to use for rendering.
23 24 25 |
# File 'lib/tree_renderer.rb', line 23 def var_binding @var_binding end |
Instance Method Details
#save ⇒ Object
Run the rendering process
38 39 40 |
# File 'lib/tree_renderer.rb', line 38 def save all_files.each{ |file| parse_and_save(file) } end |