Class: Prompt
- Inherits:
-
Object
- Object
- Prompt
- Defined in:
- lib/kaba/prompt.rb
Class Method Summary collapse
Instance Method Summary collapse
- #clear_export ⇒ Object
-
#initialize(schema, type_name) ⇒ Prompt
constructor
A new instance of Prompt.
- #render(input, export: false) ⇒ Object
Constructor Details
#initialize(schema, type_name) ⇒ Prompt
Returns a new instance of Prompt.
2 3 4 5 |
# File 'lib/kaba/prompt.rb', line 2 def initialize(schema, type_name) @schema = schema @type_name = type_name end |
Class Method Details
.file(schema_path, type_name) ⇒ Object
22 23 24 |
# File 'lib/kaba/prompt.rb', line 22 def file(schema_path, type_name) self.new File.read(File. schema_path), type_name end |
Instance Method Details
#clear_export ⇒ Object
7 8 9 |
# File 'lib/kaba/prompt.rb', line 7 def clear_export @schema.gsub(/export\s+default\s+/, '').gsub(/export\s+/, '') end |
#render(input, export: false) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/kaba/prompt.rb', line 11 def render(input, export: false) schema = export ? clear_export : @schema request_body = { schema: schema, typeName: @type_name, input: input } resp = Application.connection.post('/prompt', request_body).body end |