Module: AzureSearch

Defined in:
lib/azure_search/search_index_client.rb,
lib/azure_search/utils.rb,
lib/azure_search/errors.rb,
lib/azure_search/version.rb,
lib/azure_search/index_field.rb,
lib/azure_search/index_search_options.rb,
lib/azure_search/index_batch_operation.rb

Overview

Core module common across the entire API.

Author:

  • Faissal Elamraoui

Since:

  • 0.1.0

Defined Under Namespace

Modules: Errors Classes: IndexBatchOperation, IndexDeleteOperation, IndexField, IndexSearchOptions, IndexUploadOperation, SearchIndexClient

Constant Summary collapse

VERSION =
"0.1.0".freeze
API_VERSION =

Since:

  • 0.1.0

"2016-09-01".freeze

Instance Method Summary collapse

Instance Method Details

#has_html?(text) ⇒ TrueClass, FalseClass

Checks if the supplied text contains valid HTML.

Parameters:

  • text (String)

    The text to check.

Returns:

  • (TrueClass, FalseClass)

    true or false.



15
# File 'lib/azure_search/utils.rb', line 15

def has_html?(text); Nokogiri::XML(text).errors.empty? end

#is_bool?(value) ⇒ TrueClass, FalseClass

Checks if the supplied value is a Boolean.

Parameters:

  • value (Object)

    The value to check.

Returns:

  • (TrueClass, FalseClass)

    true or false.



9
# File 'lib/azure_search/utils.rb', line 9

def is_bool?(value); [true, false].include? value end

#to_query_string(params) ⇒ String

Converts a Hash into query parameters string.

Parameters:

  • params (Hash)

    The hash to convert.

Returns:

  • (String)

    query string.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/azure_search/utils.rb', line 21

def to_query_string(params)
  params.map{|k,v|
    if v.nil?
      k.to_s
    elsif v.respond_to?(:to_ary)
      v.to_ary.map{|w|
        str = k.to_s.dup
        unless w.nil?
          str << '='
          str << w.to_s
        end
      }.join('&')
    else
      str = k.to_s.dup
      str << '='
      str << v.to_s
    end
  }.join('&')
end