Class: ChatgptRb::Parameter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, enum: nil, type: nil, description: nil, required: false) ⇒ Parameter

Returns a new instance of Parameter.

Parameters:

  • name (String)
  • enum (defaults to: nil)
  • type (defaults to: nil)
  • description (defaults to: nil)
  • required (true, false) (defaults to: false)

    whether or not this parameter is required



10
11
12
13
14
15
16
# File 'lib/chatgpt_rb/parameter.rb', line 10

def initialize(name:, enum: nil, type: nil, description: nil, required: false)
  @name = name
  @enum = enum
  @type = type
  @description = description
  @required = required
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



3
4
5
# File 'lib/chatgpt_rb/parameter.rb', line 3

def description
  @description
end

#enumObject

Returns the value of attribute enum.



3
4
5
# File 'lib/chatgpt_rb/parameter.rb', line 3

def enum
  @enum
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/chatgpt_rb/parameter.rb', line 3

def name
  @name
end

#requiredObject

Returns the value of attribute required.



3
4
5
# File 'lib/chatgpt_rb/parameter.rb', line 3

def required
  @required
end

#typeObject

Returns the value of attribute type.



3
4
5
# File 'lib/chatgpt_rb/parameter.rb', line 3

def type
  @type
end

Instance Method Details

#as_jsonObject

Returns Hash.

Returns:

  • Hash



23
24
25
26
27
28
29
# File 'lib/chatgpt_rb/parameter.rb', line 23

def as_json
  {
    enum:,
    type:,
    description:,
  }.compact
end

#required?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/chatgpt_rb/parameter.rb', line 18

def required?
  !!required
end