Class: Makasi::AsariResult
- Inherits:
-
Object
- Object
- Makasi::AsariResult
- Includes:
- ActionView::Helpers
- Defined in:
- lib/makasi/asari_result.rb
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #highlighted_url ⇒ Object
-
#initialize(asari_result, query) ⇒ AsariResult
constructor
A new instance of AsariResult.
- #snippet ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(asari_result, query) ⇒ AsariResult
Returns a new instance of AsariResult.
7 8 9 10 11 |
# File 'lib/makasi/asari_result.rb', line 7 def initialize(asari_result, query) @url = asari_result["url"] @asari_result = asari_result @query = query end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
5 6 7 |
# File 'lib/makasi/asari_result.rb', line 5 def url @url end |
Instance Method Details
#highlighted_url ⇒ Object
13 14 15 |
# File 'lib/makasi/asari_result.rb', line 13 def highlighted_url highlight url end |
#snippet ⇒ Object
21 22 23 24 |
# File 'lib/makasi/asari_result.rb', line 21 def snippet text = HTMLEntities.new.decode (@asari_result["content"].to_s).gsub(/\s+/, ' ') highlight truncate(snippet_containing_query(text), length: 130) end |
#title ⇒ Object
17 18 19 |
# File 'lib/makasi/asari_result.rb', line 17 def title highlight @asari_result["resource_name"].to_s end |