Class: Luogu::PromptTemplate

Inherits:
Object
  • Object
show all
Defined in:
lib/luogu/prompt_template.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_path) ⇒ PromptTemplate

Returns a new instance of PromptTemplate.



3
4
5
6
# File 'lib/luogu/prompt_template.rb', line 3

def initialize(file_path)
  @file_path = file_path
  @template = ERB.new(File.read(@file_path), trim_mode: '-')
end

Class Method Details

.load(file_path) ⇒ Object



15
16
17
# File 'lib/luogu/prompt_template.rb', line 15

def load(file_path)
  self.new(file_path)
end

.load_template(file_name) ⇒ Object



19
20
21
# File 'lib/luogu/prompt_template.rb', line 19

def load_template(file_name)
  self.new File.join(File.dirname(__FILE__), 'templates', file_name)
end

Instance Method Details

#result(_binding_ = nil) ⇒ Object Also known as: render



8
9
10
# File 'lib/luogu/prompt_template.rb', line 8

def result(_binding_ = nil)
  @template.result(_binding_ || binding)
end