Class: RedmineCLI::TemplateRenderer::ErbEnvironment

Inherits:
Object
  • Object
show all
Includes:
Helpers::Output
Defined in:
lib/redmine_cli/template_renderer.rb

Overview

Class for renderer. Don’t use it outside

Instance Method Summary collapse

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

#renderObject



42
43
44
# File 'lib/redmine_cli/template_renderer.rb', line 42

def render
  ERB.new(@template, nil, '%<>').result(binding)
end