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
# File 'lib/ayadn/search.rb', line 6

def initialize api, view, workers
  @api = api
  @view = view
  @workers = workers
end

Instance Method Details

#find(words, options) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/ayadn/search.rb', line 29

def find(words, options)
  Settings.options.timeline.compact = true if options[:compact]
  Settings.global.force = true if options[:force]
  @view.downloading(options)
  stream = get_stream(words, options)
  if options[:users]
    stream_object = stream["data"].map { |user| UserObject.new(user) }
  elsif !options[:channels]
    stream_object = StreamObject.new(stream)
  end
  if options[:users]
    get_users(stream_object, options)
  elsif options[:channels]
    get_channels(stream, options)
  else
    get_generic(stream_object, words, options)
  end
  if Settings.options.timeline.compact && !options[:raw]
    puts "\n" 
  end
end

#hashtag(hashtag, options) ⇒ Object



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

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