Class: ClaudeMemory::Core::TextBuilder
- Inherits:
-
Object
- Object
- ClaudeMemory::Core::TextBuilder
- Defined in:
- lib/claude_memory/core/text_builder.rb
Overview
Pure logic for building searchable text from structured data Follows Functional Core pattern - no I/O, just transformations
Class Method Summary collapse
-
.build_searchable_text(entities, facts, decisions) ⇒ String
Build searchable text from entities, facts, and decisions.
-
.symbolize_keys(hash) ⇒ Hash
Transform hash keys from strings to symbols.
-
.truncate(text, max_length, suffix: "...") ⇒ String
Truncate text to a maximum length with a suffix.
Class Method Details
.build_searchable_text(entities, facts, decisions) ⇒ String
Build searchable text from entities, facts, and decisions
13 14 15 16 17 18 19 |
# File 'lib/claude_memory/core/text_builder.rb', line 13 def self.build_searchable_text(entities, facts, decisions) parts = [] entities.each { |e| parts << "#{e[:type]}: #{e[:name]}" } facts.each { |f| parts << "#{f[:subject]} #{f[:predicate]} #{f[:object]} #{f[:quote]}" } decisions.each { |d| parts << "#{d[:title]} #{d[:summary]}" } parts.join(" ").strip end |
.symbolize_keys(hash) ⇒ Hash
Transform hash keys from strings to symbols
35 36 37 |
# File 'lib/claude_memory/core/text_builder.rb', line 35 def self.symbolize_keys(hash) hash.transform_keys(&:to_sym) end |
.truncate(text, max_length, suffix: "...") ⇒ String
Truncate text to a maximum length with a suffix
26 27 28 29 30 |
# File 'lib/claude_memory/core/text_builder.rb', line 26 def self.truncate(text, max_length, suffix: "...") return "" if text.nil? return text if text.length <= max_length text[0, max_length] + suffix end |