Class: Ferret::Search::Explanation
- Inherits:
-
Object
- Object
- Ferret::Search::Explanation
- Defined in:
- lib/ferret/search/explanation.rb
Overview
Expert: Describes the score computation for document and query.
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#details ⇒ Object
Returns the value of attribute details.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #<<(detail) ⇒ Object
-
#initialize(value = nil, description = nil) ⇒ Explanation
constructor
A new instance of Explanation.
-
#to_html ⇒ Object
Render an explanation as HTML.
-
#to_s(depth = 0) ⇒ Object
Render an explanation as text.
Constructor Details
#initialize(value = nil, description = nil) ⇒ Explanation
Returns a new instance of Explanation.
6 7 8 9 10 |
# File 'lib/ferret/search/explanation.rb', line 6 def initialize(value = nil, description = nil) @value = value @description = description @details = [] end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
4 5 6 |
# File 'lib/ferret/search/explanation.rb', line 4 def description @description end |
#details ⇒ Object
Returns the value of attribute details.
4 5 6 |
# File 'lib/ferret/search/explanation.rb', line 4 def details @details end |
#value ⇒ Object
Returns the value of attribute value.
4 5 6 |
# File 'lib/ferret/search/explanation.rb', line 4 def value @value end |
Instance Method Details
#<<(detail) ⇒ Object
12 13 14 |
# File 'lib/ferret/search/explanation.rb', line 12 def <<(detail) @details << detail end |
#to_html ⇒ Object
Render an explanation as HTML.
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ferret/search/explanation.rb', line 28 def to_html() buffer = "<ul>\n" buffer << "<li>#{@value} = #{@description}</li>\n" @details.each do |detail| buffer << detail.to_html end buffer << "</ul>\n" return buffer end |
#to_s(depth = 0) ⇒ Object
Render an explanation as text.
17 18 19 20 21 22 23 24 25 |
# File 'lib/ferret/search/explanation.rb', line 17 def to_s(depth = 0) buffer = " " * depth buffer << "#{@value} = #{@description}\n" @details.each do |detail| buffer << detail.to_s(depth + 1) end return buffer end |