Sha256: 75d472463c433ec12e61f011e9e92a1b23137ed664923921eb6541cbb017b1a3

Contents?: true

Size: 595 Bytes

Versions: 1

Compression:

Stored size: 595 Bytes

Contents

class ThinkingSphinx::Excerpter
  DefaultOptions = {
    :before_match    => '<span class="match">',
    :after_match     => '</span>',
    :chunk_separator => ' &#8230; ' # ellipsis
  }

  attr_accessor :index, :words, :options

  def initialize(index, words, options = {})
    @index, @words = index, words
    @options = DefaultOptions.merge(options)
  end

  def excerpt!(text)
    connection.query(Riddle::Query.snippets(text, index, words, options)).
      first['snippet']
  end

  private

  def connection
    @connection ||= ThinkingSphinx::Configuration.instance.connection
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
thinking-sphinx-3.0.0.pre lib/thinking_sphinx/excerpter.rb