Class: Twterm::Completer::SearchQueryCompleter
- Inherits:
-
AbstractCompleter
- Object
- AbstractCompleter
- Twterm::Completer::SearchQueryCompleter
- Defined in:
- lib/twterm/completer/search_query_completer.rb
Instance Method Summary collapse
Methods inherited from AbstractCompleter
#basic_word_break_characters, #initialize
Constructor Details
This class inherits a constructor from Twterm::Completer::AbstractCompleter
Instance Method Details
#complete(q) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/twterm/completer/search_query_completer.rb', line 10 def complete(q) possible_operators = possible_operators_for_query(q) if q.empty? operators elsif q.start_with?('#') app.hashtag_repository.all .map { |tag| "##{tag.text} " } .select { |tag| tag.start_with?(q) } elsif q.start_with?('@') app.user_repository.all .map { |user| "@#{user.screen_name} " } .select { |name| name.start_with?(q) } elsif !possible_operators.empty? possible_operators elsif q.start_with?('-from:') app.user_repository.all .map { |user| "-from:#{user.screen_name} " } .select { |name| name.start_with?(q) } elsif q.start_with?('from:') app.user_repository.all .map { |user| "from:#{user.screen_name} " } .select { |name| name.start_with?(q) } elsif q.start_with?('-to:') app.user_repository.all .map { |user| "-to:#{user.screen_name} " } .select { |name| name.start_with?(q) } elsif q.start_with?('to:') app.user_repository.all .map { |user| "to:#{user.screen_name} " } .select { |name| name.start_with?(q) } elsif q.start_with?('filter:') filters.map { |f| "filter:#{f} " }.select { |f| f.start_with?(q) } elsif q.start_with?('-filter:') filters.map { |f| "-filter:#{f} " }.select { |f| f.start_with?(q) } elsif q.start_with?('lang:') langs.map { |l| "lang:#{l} " }.select { |l| l.start_with?(q) } elsif q.start_with?('-lang:') langs.map { |l| "-lang:#{l} " }.select { |l| l.start_with?(q) } elsif q.start_with?('list:') app.list_repository.all .map { |list| "list:#{list.full_name.sub('@', '')} " } .select { |name| name.start_with?(q) } else [] end end |
#completion_append_character ⇒ Object
6 7 8 |
# File 'lib/twterm/completer/search_query_completer.rb', line 6 def completion_append_character '' end |