Class: ThinkingSphinx::Excerpter
- Inherits:
-
Object
- Object
- ThinkingSphinx::Excerpter
- Defined in:
- lib/thinking_sphinx/excerpter.rb
Constant Summary collapse
- DefaultOptions =
{ :before_match => '<span class="match">', :after_match => '</span>', :chunk_separator => ' … ' # ellipsis }
Instance Attribute Summary collapse
-
#index ⇒ Object
Returns the value of attribute index.
-
#options ⇒ Object
Returns the value of attribute options.
-
#words ⇒ Object
Returns the value of attribute words.
Instance Method Summary collapse
- #excerpt!(text) ⇒ Object
-
#initialize(index, words, options = {}) ⇒ Excerpter
constructor
A new instance of Excerpter.
Constructor Details
#initialize(index, words, options = {}) ⇒ Excerpter
Returns a new instance of Excerpter.
10 11 12 13 14 |
# File 'lib/thinking_sphinx/excerpter.rb', line 10 def initialize(index, words, = {}) @index, @words = index, words = DefaultOptions.merge() @words = .delete(:words) if [:words] end |
Instance Attribute Details
#index ⇒ Object
Returns the value of attribute index.
8 9 10 |
# File 'lib/thinking_sphinx/excerpter.rb', line 8 def index @index end |
#options ⇒ Object
Returns the value of attribute options.
8 9 10 |
# File 'lib/thinking_sphinx/excerpter.rb', line 8 def end |
#words ⇒ Object
Returns the value of attribute words.
8 9 10 |
# File 'lib/thinking_sphinx/excerpter.rb', line 8 def words @words end |
Instance Method Details
#excerpt!(text) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/thinking_sphinx/excerpter.rb', line 16 def excerpt!(text) result = ThinkingSphinx::Connection.take do |connection| connection.query(statement_for(text)).first['snippet'] end result.encode!("ISO-8859-1") result.force_encoding("UTF-8") end |