Class: Lyra::Template
Instance Attribute Summary collapse
-
#output_path ⇒ Object
readonly
Returns the value of attribute output_path.
-
#secrets ⇒ Object
readonly
Returns the value of attribute secrets.
-
#template_path ⇒ Object
readonly
Returns the value of attribute template_path.
Instance Method Summary collapse
- #generate(output_path: String) ⇒ Object
-
#initialize(secrets: Array, template_path: String) ⇒ Template
constructor
A new instance of Template.
- #render ⇒ Object
Constructor Details
#initialize(secrets: Array, template_path: String) ⇒ Template
Returns a new instance of Template.
9 10 11 12 |
# File 'lib/lyra/template.rb', line 9 def initialize(secrets: Array, template_path: String) @secrets = secrets @template_path = template_path end |
Instance Attribute Details
#output_path ⇒ Object (readonly)
Returns the value of attribute output_path.
7 8 9 |
# File 'lib/lyra/template.rb', line 7 def output_path @output_path end |
#secrets ⇒ Object (readonly)
Returns the value of attribute secrets.
5 6 7 |
# File 'lib/lyra/template.rb', line 5 def secrets @secrets end |
#template_path ⇒ Object (readonly)
Returns the value of attribute template_path.
6 7 8 |
# File 'lib/lyra/template.rb', line 6 def template_path @template_path end |
Instance Method Details
#generate(output_path: String) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/lyra/template.rb', line 18 def generate(output_path: String) File.open(output_path, 'w+') do |f| f.write(render) f.close end end |
#render ⇒ Object
14 15 16 |
# File 'lib/lyra/template.rb', line 14 def render ERB.new(File.read(@template_path), trim_mode: '<>').result(binding) end |