Class: Gugl::Search::Searcher

Inherits:
Object
  • Object
show all
Defined in:
lib/search/searcher.rb

Constant Summary collapse

DEFAULT_LIMIT =
5

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#limitObject

Returns the value of attribute limit.



8
9
10
# File 'lib/search/searcher.rb', line 8

def limit
  @limit
end

#queryObject

Returns the value of attribute query.



8
9
10
# File 'lib/search/searcher.rb', line 8

def query
  @query
end

#resultsObject (readonly)

Returns the value of attribute results.



7
8
9
# File 'lib/search/searcher.rb', line 7

def results
  @results
end

Instance Method Details

#authorize(&blk) ⇒ Object



23
24
25
# File 'lib/search/searcher.rb', line 23

def authorize(&blk)
  getter.searcher.authorize(&blk)
end

#displayObject



17
18
19
20
21
# File 'lib/search/searcher.rb', line 17

def display
  results.each_with_index.map do |result, index|
    displayer.display result, index
  end
end

#displayerObject



40
41
42
# File 'lib/search/searcher.rb', line 40

def displayer
  @displayer ||= mapped_displayer(:default)
end

#displayer=(displayer) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/search/searcher.rb', line 32

def displayer=(displayer)
  @displayer = if displayer.is_a?(Symbol)
    mapped_displayer(displayer)
  else
    displayer
  end
end

#searchObject



12
13
14
15
# File 'lib/search/searcher.rb', line 12

def search
  configure_getter
  @results = getter.get
end

#search_and_displayObject



27
28
29
30
# File 'lib/search/searcher.rb', line 27

def search_and_display
  search
  display
end