Class: RedmineCLI::TemplateRenderer::ErbEnvironment
- Inherits:
-
Object
- Object
- RedmineCLI::TemplateRenderer::ErbEnvironment
- Includes:
- Helpers::Output
- Defined in:
- lib/redmine_cli/template_renderer.rb
Overview
Class for renderer. Don’t use it outside
Instance Method Summary collapse
-
#initialize(template, vars = {}) ⇒ ErbEnvironment
constructor
A new instance of ErbEnvironment.
- #method_missing(m, *args) ⇒ Object
- #render ⇒ Object
Methods included from Helpers::Output
#erb, #message, #print_object_list, #print_prompt_message
Constructor Details
#initialize(template, vars = {}) ⇒ ErbEnvironment
Returns a new instance of ErbEnvironment.
31 32 33 34 |
# File 'lib/redmine_cli/template_renderer.rb', line 31 def initialize(template, vars = {}) @template = template @vars = vars end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args) ⇒ Object
36 37 38 39 40 |
# File 'lib/redmine_cli/template_renderer.rb', line 36 def method_missing(m, *args) return @vars[m] if args.empty? && @vars.key?(m) super end |
Instance Method Details
#render ⇒ Object
42 43 44 |
# File 'lib/redmine_cli/template_renderer.rb', line 42 def render ERB.new(@template, nil, '%<>').result(binding) end |