Class: HighLine::TemplateRenderer
- Extended by:
- Forwardable
- Defined in:
- lib/highline/template_renderer.rb
Overview
Instance Attribute Summary collapse
-
#highline ⇒ HighLine
readonly
HighLine instance used as context.
-
#source ⇒ Question, Menu
readonly
Question instance used as context.
-
#template ⇒ ERB
readonly
ERB template being rendered.
Class Method Summary collapse
-
.const_missing(name) ⇒ Object
If some constant is missing at this TemplateRenderer instance, get it from HighLine.
Instance Method Summary collapse
-
#initialize(template, source, highline) ⇒ TemplateRenderer
constructor
Initializes the TemplateRenderer object with its template and HighLine and Question contexts.
-
#menu ⇒ Question, Menu
#source attribute.
-
#method_missing(method, *args) ⇒ String
Returns an error message when the called method is not available.
-
#render ⇒ String
Rendered template.
Constructor Details
#initialize(template, source, highline) ⇒ TemplateRenderer
Initializes the TemplateRenderer object with its template and HighLine and Question contexts.
30 31 32 33 34 |
# File 'lib/highline/template_renderer.rb', line 30 def initialize(template, source, highline) @template = template @source = source @highline = highline end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ String
Returns an error message when the called method is not available.
44 45 46 47 48 |
# File 'lib/highline/template_renderer.rb', line 44 def method_missing(method, *args) "Method #{method} with args #{args.inspect} " \ "is not available on #{inspect}. " \ "Try #{methods(false).sort.inspect}" end |
Instance Attribute Details
#highline ⇒ HighLine (readonly)
Returns HighLine instance used as context.
21 22 23 |
# File 'lib/highline/template_renderer.rb', line 21 def highline @highline end |
#source ⇒ Question, Menu (readonly)
Returns Question instance used as context.
18 19 20 |
# File 'lib/highline/template_renderer.rb', line 18 def source @source end |
#template ⇒ ERB (readonly)
Returns ERB template being rendered.
15 16 17 |
# File 'lib/highline/template_renderer.rb', line 15 def template @template end |