Class: IRust::TemplateRenderer
- Inherits:
-
Object
- Object
- IRust::TemplateRenderer
- Defined in:
- lib/irust/template_renderer.rb
Constant Summary collapse
- RUST_TEMPLATE =
File.("../template.rs.erb", __FILE__)
Instance Attribute Summary collapse
-
#history ⇒ Object
readonly
Returns the value of attribute history.
-
#rust_code ⇒ Object
readonly
Returns the value of attribute rust_code.
Instance Method Summary collapse
-
#initialize(rust_code, history = nil) ⇒ TemplateRenderer
constructor
A new instance of TemplateRenderer.
- #let_var ⇒ Object
- #render ⇒ Object
Constructor Details
#initialize(rust_code, history = nil) ⇒ TemplateRenderer
Returns a new instance of TemplateRenderer.
9 10 11 |
# File 'lib/irust/template_renderer.rb', line 9 def initialize(rust_code, history = nil) @rust_code, @history = rust_code, history end |
Instance Attribute Details
#history ⇒ Object (readonly)
Returns the value of attribute history.
7 8 9 |
# File 'lib/irust/template_renderer.rb', line 7 def history @history end |
#rust_code ⇒ Object (readonly)
Returns the value of attribute rust_code.
7 8 9 |
# File 'lib/irust/template_renderer.rb', line 7 def rust_code @rust_code end |
Instance Method Details
#let_var ⇒ Object
18 19 20 |
# File 'lib/irust/template_renderer.rb', line 18 def let_var rust_code[/^\s*(let|fn)\s+(mut\s+)?(\w+)/, 3] end |
#render ⇒ Object
13 14 15 16 |
# File 'lib/irust/template_renderer.rb', line 13 def render template = File.read(RUST_TEMPLATE) ERB.new(template).result(binding) end |