Class: RubyLLM::Registry::RenderContext
- Inherits:
-
Object
- Object
- RubyLLM::Registry::RenderContext
show all
- Defined in:
- lib/ruby_llm/registry/context.rb
Overview
Context object used while rendering ERB prompts.
Instance Method Summary
collapse
Constructor Details
#initialize(values = {}) ⇒ RenderContext
Returns a new instance of RenderContext.
7
8
9
|
# File 'lib/ruby_llm/registry/context.rb', line 7
def initialize(values = {})
@values = normalize(values)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
11
12
13
14
15
|
# File 'lib/ruby_llm/registry/context.rb', line 11
def method_missing(name, *args)
raise NoMethodError, "undefined method `#{name}` for #{self}" unless args.empty?
@values[name]
end
|
Instance Method Details
#current_date ⇒ Object
Also known as:
today
21
22
23
|
# File 'lib/ruby_llm/registry/context.rb', line 21
def current_date
Date.today
end
|
#current_time ⇒ Object
25
26
27
|
# File 'lib/ruby_llm/registry/context.rb', line 25
def current_time
Time.now
end
|
#respond_to_missing?(name, _include_private = false) ⇒ Boolean
17
18
19
|
# File 'lib/ruby_llm/registry/context.rb', line 17
def respond_to_missing?(name, _include_private = false)
@values.key?(name)
end
|