Module: RubyLLM::Support::Inspectable
- Included in:
- Accounting::Usage::Entry, Attachment, Batch, CachedContent, Chat, Citation, Cost, DownloadedFile, Embedding, EmbeddingRequest, Fallback, Image, Message, Model, Moderation, OCR, Provider, Rerank, ResearchJob, RubyLLM::ServerToolCall, RubyLLM::Speech, RubyLLM::SpeechChunk, Thinking, Tokenization, Tokens, ToolCall, Transcription, TranscriptionChunk, Transport::Connection, UploadedFile, Video, VideoJob
- Defined in:
- lib/ruby_llm/support/inspectable.rb
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
-
#full_inspect ⇒ Object
Returns the stock Ruby dump with every instance variable, for when the one-line summary is not enough.
-
#inspect ⇒ Object
Returns a one-line summary of the object built from its
inspect_attributes, omitting empty ones and truncating long values. -
#pretty_print(printer) ⇒ Object
:nodoc:.
Instance Method Details
#full_inspect ⇒ Object
Returns the stock Ruby dump with every instance variable, for when the one-line summary is not enough.
.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 |
#inspect ⇒ Object
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 |