Class: Ayadn::Search

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

Instance Method Summary collapse

Constructor Details

#initialize(api, view, workers) ⇒ Search

Returns a new instance of Search.



6
7
8
9
10
11
# File 'lib/ayadn/search.rb', line 6

def initialize api, view, workers
  @api = api
  @view = view
  @workers = workers
  @check = Check.new
end

Instance Method Details

#find(words, options) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/ayadn/search.rb', line 28

def find(words, options)
  Settings.global[:force] = true if options[:force]
  @view.downloading(options)
  stream = get_stream(words, options)
  @check.no_data(stream, 'search')
  if options[:users]
    get_users(stream, options)
  elsif options[:channels]
    get_channels(stream, options)
  else
    get_generic(stream, words, options)
  end
  if Settings.options[:timeline][:compact] == true && !options[:raw]
    puts "\n" 
  end
end

#hashtag(hashtag, options) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ayadn/search.rb', line 13

def hashtag(hashtag, options)
  Settings.global[:force] = true if options[:force]
  @view.downloading(options)
  stream = @api.get_hashtag(hashtag)
  @check.no_data(stream, 'hashtag')
  if options[:extract]
    @view.all_hashtag_links(stream, hashtag)
  else
    @view.render(stream, options)
    if Settings.options[:timeline][:compact] == true && !options[:raw]
      puts "\n" 
    end
  end
end