Class: Emojidex::Service::Search

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

Overview

Search functionality for the emojidex service

Class Method Summary collapse

Class Method Details

.advanced(code_cont, categories = [], tags = [], opts = {}) ⇒ Object

An expanded version of term with categories and tags as arguments. Options are: detailed: set to true to enable detailed results (defaults to false) limit: sets the number of items per page (default Emojidex::Defaults.limit) Returns a service Collection.



54
55
56
57
58
59
60
61
# File 'lib/emojidex/service/search.rb', line 54

def self.advanced(code_cont, categories = [], tags = [], opts = {})
  opts[:code_cont] = Emojidex.escape_code(code_cont)
  tags = [] << tags unless tags.class == Array
  opts[:tags] = tags
  categories = [] << categories unless categories.class == Array
  opts[:categories] = categories
  _do_search(opts)
end

.ending(code_ew, opts = {}) ⇒ Object

Searches for a code ending with the given term. Available options are the same as term. Returns a service Collection.



35
36
37
38
# File 'lib/emojidex/service/search.rb', line 35

def self.ending(code_ew, opts = {})
  opts[:code_ew] = Emojidex.escape_code(code_ew)
  _do_search(opts)
end

.search(code_cont, opts = {}) ⇒ Object



20
21
22
# File 'lib/emojidex/service/search.rb', line 20

def self.search(code_cont, opts = {})
  term(code_cont, opts)
end

.starting(code_sw, opts = {}) ⇒ Object

Searches for a code starting with the given term. Available options are the same as term. Returns a service Collection.



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

def self.starting(code_sw, opts = {})
  opts[:code_sw] = Emojidex.escape_code(code_sw)
  _do_search(opts)
end

.tags(tags, opts = {}) ⇒ Object

Searches an array of tags for emoji associated with all those tags. Available options are the same as term. Returns a service Collection.



43
44
45
46
47
# File 'lib/emojidex/service/search.rb', line 43

def self.tags(tags, opts = {})
  tags = [] << tags unless tags.class == Array
  opts[:tags] = tags
  _do_search(opts)
end

.term(code_cont, opts = {}) ⇒ Object

Searches by term with the options given. Options are: tags: an array of tags to restrict the search to categories: an arry of categories to restrict the serach to detailed: set to true to enable detailed results (defaults to false) limit: sets the number of items per page (default Emojidex::Defaults.limit) Returns a service Collection.



15
16
17
18
# File 'lib/emojidex/service/search.rb', line 15

def self.term(code_cont, opts = {})
  opts[:code_cont] = Emojidex.escape_code(code_cont)
  _do_search(opts)
end