class ThinkingSphinx::Excerpter
Constants
- DefaultOptions
Attributes
index[RW]
options[RW]
words[RW]
Public Class Methods
new(index, words, options = {})
click to toggle source
# File lib/thinking_sphinx/excerpter.rb, line 10 def initialize(index, words, options = {}) @index, @words = index, words @options = DefaultOptions.merge(options) @words = @options.delete(:words) if @options[:words] end
Public Instance Methods
excerpt!(text)
click to toggle source
# File lib/thinking_sphinx/excerpter.rb, line 16 def excerpt!(text) result = ThinkingSphinx::Connection.take do |connection| connection.execute(statement_for(text)).first['snippet'] end encoded? ? result : ThinkingSphinx::UTF8.encode(result) end
Private Instance Methods
encoded?()
click to toggle source
# File lib/thinking_sphinx/excerpter.rb, line 30 def encoded? ThinkingSphinx::Configuration.instance.settings['utf8'].nil? || ThinkingSphinx::Configuration.instance.settings['utf8'] end
statement_for(text)
click to toggle source
# File lib/thinking_sphinx/excerpter.rb, line 26 def statement_for(text) Riddle::Query.snippets(text, index, words, options) end