Class: Makasi::AsariResult

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers
Defined in:
lib/makasi/asari_result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#urlObject (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_urlObject



13
14
15
# File 'lib/makasi/asari_result.rb', line 13

def highlighted_url
  highlight url
end

#snippetObject



21
22
23
24
# File 'lib/makasi/asari_result.rb', line 21

def snippet
  text = HTMLEntities.new.decode strip_tags(@asari_result["content"].to_s).gsub(/\s+/, ' ')
  highlight truncate(snippet_containing_query(text), length: 130)
end

#titleObject



17
18
19
# File 'lib/makasi/asari_result.rb', line 17

def title
  highlight @asari_result["resource_name"].to_s
end