Class: HotwireClub::MCP::Chunk
- Inherits:
-
Data
- Object
- Data
- HotwireClub::MCP::Chunk
- Defined in:
- lib/hotwire_club/mcp/chunk.rb
Overview
Data class representing a single chunk of a document
Instance Attribute Summary collapse
-
#category ⇒ Object
readonly
Returns the value of attribute category.
-
#doc_id ⇒ Object
readonly
Returns the value of attribute doc_id.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#position ⇒ Object
readonly
Returns the value of attribute position.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Class Method Summary collapse
-
.build_chunk_id(doc_id, section_idx, part_idx) ⇒ String
Build chunk ID from document ID, section index, and part index.
-
.create_from_section(doc:, section_idx:, part_idx:, section_title:, text:, position:) ⇒ Chunk
Create a chunk from a document section.
Instance Attribute Details
#category ⇒ Object (readonly)
Returns the value of attribute category
6 7 8 |
# File 'lib/hotwire_club/mcp/chunk.rb', line 6 def category @category end |
#doc_id ⇒ Object (readonly)
Returns the value of attribute doc_id
6 7 8 |
# File 'lib/hotwire_club/mcp/chunk.rb', line 6 def doc_id @doc_id end |
#id ⇒ Object (readonly)
Returns the value of attribute id
6 7 8 |
# File 'lib/hotwire_club/mcp/chunk.rb', line 6 def id @id end |
#position ⇒ Object (readonly)
Returns the value of attribute position
6 7 8 |
# File 'lib/hotwire_club/mcp/chunk.rb', line 6 def position @position end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags
6 7 8 |
# File 'lib/hotwire_club/mcp/chunk.rb', line 6 def @tags end |
#text ⇒ Object (readonly)
Returns the value of attribute text
6 7 8 |
# File 'lib/hotwire_club/mcp/chunk.rb', line 6 def text @text end |
#title ⇒ Object (readonly)
Returns the value of attribute title
6 7 8 |
# File 'lib/hotwire_club/mcp/chunk.rb', line 6 def title @title end |
Class Method Details
.build_chunk_id(doc_id, section_idx, part_idx) ⇒ String
Build chunk ID from document ID, section index, and part index
36 37 38 39 40 41 42 |
# File 'lib/hotwire_club/mcp/chunk.rb', line 36 def self.build_chunk_id(doc_id, section_idx, part_idx) if part_idx.zero? "#{doc_id}#s#{section_idx}" else "#{doc_id}#s#{section_idx}-#{part_idx}" end end |
.create_from_section(doc:, section_idx:, part_idx:, section_title:, text:, position:) ⇒ Chunk
Create a chunk from a document section
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/hotwire_club/mcp/chunk.rb', line 16 def self.create_from_section(doc:, section_idx:, part_idx:, section_title:, text:, position:) chunk_id = build_chunk_id(doc.id, section_idx, part_idx) new( id: chunk_id, doc_id: doc.id, title: section_title, category: doc.category, tags: doc., position: position, text: text, ) end |