Class: Brainchat::Retriever::Chunk

Inherits:
Data
  • Object
show all
Defined in:
lib/brainchat/retriever.rb

Overview

One retrieved chunk. Data.define gives an immutable value object with free keyword construction, matching the Finding idiom in leakless.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#end_lineObject (readonly)

Returns the value of attribute end_line

Returns:

  • (Object)

    the current value of end_line



24
25
26
# File 'lib/brainchat/retriever.rb', line 24

def end_line
  @end_line
end

#pathObject (readonly)

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



24
25
26
# File 'lib/brainchat/retriever.rb', line 24

def path
  @path
end

#rankObject (readonly)

Returns the value of attribute rank

Returns:

  • (Object)

    the current value of rank



24
25
26
# File 'lib/brainchat/retriever.rb', line 24

def rank
  @rank
end

#repoObject (readonly)

Returns the value of attribute repo

Returns:

  • (Object)

    the current value of repo



24
25
26
# File 'lib/brainchat/retriever.rb', line 24

def repo
  @repo
end

#source_typeObject (readonly)

Returns the value of attribute source_type

Returns:

  • (Object)

    the current value of source_type



24
25
26
# File 'lib/brainchat/retriever.rb', line 24

def source_type
  @source_type
end

#start_lineObject (readonly)

Returns the value of attribute start_line

Returns:

  • (Object)

    the current value of start_line



24
25
26
# File 'lib/brainchat/retriever.rb', line 24

def start_line
  @start_line
end

#symbolObject (readonly)

Returns the value of attribute symbol

Returns:

  • (Object)

    the current value of symbol



24
25
26
# File 'lib/brainchat/retriever.rb', line 24

def symbol
  @symbol
end

#textObject (readonly)

Returns the value of attribute text

Returns:

  • (Object)

    the current value of text



24
25
26
# File 'lib/brainchat/retriever.rb', line 24

def text
  @text
end

Instance Method Details

#locationObject

"path:12-40", or just "path" for chunks without line information (git-commit chunks carry start_line/end_line of 0).



27
28
29
30
31
# File 'lib/brainchat/retriever.rb', line 27

def location
  return path.to_s if start_line.to_i.zero? && end_line.to_i.zero?

  "#{path}:#{start_line}-#{end_line}"
end