Module: BingSearch

Defined in:
lib/bing-search.rb,
lib/bing-search/util.rb,
lib/bing-search/enums.rb,
lib/bing-search/client.rb,
lib/bing-search/errors.rb,
lib/bing-search/models.rb,
lib/bing-search/version.rb

Defined Under Namespace

Modules: Adult, FileType, ImageFilter, NewsCategory, NewsSort, Source, VideoFilter, VideoSort Classes: Client, CompositeSearchResult, Image, ImageResult, Model, NewsResult, RelatedSearchResult, Result, ServiceError, SpellingSuggestionsResult, VideoResult, WebResult

Constant Summary collapse

HIGHLIGHT_DELIMITER =
"\u{e001}"
VERSION =
'2.0.0'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.account_keyString

An Account Key obtained from the Azure Marketplace. You can set this attribute once instead of instantiating each Client with an Account Key.

Returns:

  • (String)


20
21
22
# File 'lib/bing-search.rb', line 20

def 
  @account_key
end

.web_onlyBoolean

Whether to use the less expensive web-only API

Returns:

  • (Boolean)


24
25
26
# File 'lib/bing-search.rb', line 24

def web_only
  @web_only
end

Class Method Details

.composite(*args) ⇒ CompositeSearchResult

Convenience method that creates a Client and searches multiple sources. Takes the same arguments as BingSearch::Client#related_search. Set account_key before calling.



90
91
92
# File 'lib/bing-search.rb', line 90

def composite(*args)
  Client.new.composite(*args)
end

.image(*args) ⇒ Array<ImageResult>

Convenience method that creates a Client and searches for images. Takes the same arguments as BingSearch::Client#image. Set account_key before calling.

Returns:

See Also:



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

def image(*args)
  Client.new.image(*args)
end

.news(*args) ⇒ Array<NewsResult>

Convenience method that creates a Client and searches for news. Takes the same arguments as BingSearch::Client#news. Set account_key before calling.

Returns:

See Also:



58
59
60
# File 'lib/bing-search.rb', line 58

def news(*args)
  Client.new.news(*args)
end

Convenience method that creates a Client and searches for related queries. Takes the same arguments as BingSearch::Client#related_search. Set account_key before calling.



68
69
70
# File 'lib/bing-search.rb', line 68

def related_search(*args)
  Client.new.related_search(*args)
end

.spelling_suggestions(*args) ⇒ Array<SpellingSuggestionsResult> Also known as: spelling

Convenience method that creates a Client and corrects spelling in the query text. Takes the same arguments as BingSearch::Client#related_search. Set account_key before calling.



79
80
81
# File 'lib/bing-search.rb', line 79

def spelling_suggestions(*args)
  Client.new.spelling_suggestions(*args)
end

.video(*args) ⇒ Array<VideoResult>

Convenience method that creates a Client and searches for videos. Takes the same arguments as BingSearch::Client#video. Set account_key before calling.

Returns:

See Also:



49
50
51
# File 'lib/bing-search.rb', line 49

def video(*args)
  Client.new.video(*args)
end

.web(*args) ⇒ Array<WebResult>

Convenience method that creates a Client and searches for web pages. Takes the same arguments as BingSearch::Client#web. Set account_key before calling.

Returns:

See Also:



31
32
33
# File 'lib/bing-search.rb', line 31

def web(*args)
  Client.new.web(*args)
end