Class: Asciidoctor::Standoc::YamlContextRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/asciidoctor/standoc/macros_yaml2text.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context_object:, context_name:) ⇒ YamlContextRenderer

Returns a new instance of YamlContextRenderer.



28
29
30
31
# File 'lib/asciidoctor/standoc/macros_yaml2text.rb', line 28

def initialize(context_object:, context_name:)
  @context_object = context_object
  @context_name = context_name
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *_args) ⇒ Object



37
38
39
40
41
# File 'lib/asciidoctor/standoc/macros_yaml2text.rb', line 37

def method_missing(name, *_args)
  return context_object if name.to_s == context_name

  super
end

Instance Attribute Details

#context_nameObject (readonly)

Returns the value of attribute context_name.



26
27
28
# File 'lib/asciidoctor/standoc/macros_yaml2text.rb', line 26

def context_name
  @context_name
end

#context_objectObject (readonly)

Returns the value of attribute context_object.



26
27
28
# File 'lib/asciidoctor/standoc/macros_yaml2text.rb', line 26

def context_object
  @context_object
end

Instance Method Details

#render(template) ⇒ Object



43
44
45
# File 'lib/asciidoctor/standoc/macros_yaml2text.rb', line 43

def render(template)
  ERB.new(template).result(binding)
end

#respond_to_missing?(name) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/asciidoctor/standoc/macros_yaml2text.rb', line 33

def respond_to_missing?(name)
  respond_to?(name)
end