Sha256: afc6036d1b9cbf30ab3b72ee99589708c2b54b16d68f80b497d358f5532f5c24
Contents?: true
Size: 761 Bytes
Versions: 1
Compression:
Stored size: 761 Bytes
Contents
class ThinkingSphinx::Excerpter DefaultOptions = { :before_match => '<span class="match">', :after_match => '</span>', :chunk_separator => ' … ' # ellipsis } attr_accessor :index, :words, :options def initialize(index, words, options = {}) @index, @words = index, words @options = DefaultOptions.merge(options) @words = @options.delete(:words) if @options[:words] end def excerpt!(text) result = connection.query(statement_for(text)).first['snippet'] result.encode!("ISO-8859-1") result.force_encoding("UTF-8") end private def connection @connection ||= ThinkingSphinx::Connection.new end def statement_for(text) Riddle::Query.snippets(text, index, words, options) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
thinking-sphinx-3.0.4 | lib/thinking_sphinx/excerpter.rb |