Class: ChatgptRb::DSL::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/chatgpt_rb/dsl/base.rb

Direct Known Subclasses

Conversation, Function, Parameter

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object) ⇒ Base

Returns a new instance of Base.

Parameters:



15
16
17
# File 'lib/chatgpt_rb/dsl/base.rb', line 15

def initialize(object)
  @object = object
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



12
13
14
# File 'lib/chatgpt_rb/dsl/base.rb', line 12

def object
  @object
end

Class Method Details

.configure(object, &configuration) ⇒ Chatgpt::Conversation, ...

Parameters:

Returns:



7
8
9
10
# File 'lib/chatgpt_rb/dsl/base.rb', line 7

def self.configure(object, &configuration)
  new(object).instance_eval(&configuration)
  object
end

.supported_fields(fields) ⇒ Object

Parameters:

  • shorthand (Array<Symbol>)

    for allowing the DSL to set iVars



20
21
22
23
24
25
26
# File 'lib/chatgpt_rb/dsl/base.rb', line 20

def self.supported_fields(fields)
  fields.each do |method_name|
    define_method method_name do |value|
      object.public_send("#{method_name}=", value)
    end
  end
end