Module: RubyLLM::Support::Inspectable

Overview

Concise console output, the way Active Record prints records. Including classes declare what matters in inspect_attributes; #inspect shows those on one line with long strings truncated, and pretty printing follows #inspect so IRB stays readable. Inspection is a summary, not the data: everything remains reachable through the readers (+message.raw+, embedding.vectors, chat.messages).

Constant Summary collapse

TRUNCATE_AT =

:nodoc:

64

Instance Method Summary collapse

Instance Method Details

#full_inspectObject

Returns the stock Ruby dump with every instance variable, for when the one-line summary is not enough.

message.full_inspect


34
35
36
# File 'lib/ruby_llm/support/inspectable.rb', line 34

def full_inspect
  Object.instance_method(:inspect).bind_call(self)
end

#inspectObject

Returns a one-line summary of the object built from its inspect_attributes, omitting empty ones and truncating long values.



16
17
18
19
20
21
22
23
# File 'lib/ruby_llm/support/inspectable.rb', line 16

def inspect
  attributes = inspect_attributes
               .reject { |_, value| value.nil? || (value.respond_to?(:empty?) && value.empty?) }
               .map { |name, value| "#{name}: #{format_for_inspect(value)}" }
  return "#<#{self.class.name}>" if attributes.empty?

  "#<#{self.class.name} #{attributes.join(', ')}>"
end

#pretty_print(printer) ⇒ Object

:nodoc:



25
26
27
# File 'lib/ruby_llm/support/inspectable.rb', line 25

def pretty_print(printer) # :nodoc:
  printer.text(inspect)
end