Class: Couchbase::SearchFacet::SearchFacetNumericRange

Inherits:
Object
  • Object
show all
Defined in:
lib/couchbase/search_options.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field) {|_self| ... } ⇒ SearchFacetNumericRange

Returns a new instance of SearchFacetNumericRange.

Parameters:

  • field (String)

    name of the field

Yields:

  • (_self)

Yield Parameters:



1275
1276
1277
1278
1279
# File 'lib/couchbase/search_options.rb', line 1275

def initialize(field)
  @field = field
  @ranges = []
  yield self if block_given?
end

Instance Attribute Details

#fieldString (readonly)

Returns:

  • (String)


1269
1270
1271
# File 'lib/couchbase/search_options.rb', line 1269

def field
  @field
end

#sizeInteger

Returns:

  • (Integer)


1272
1273
1274
# File 'lib/couchbase/search_options.rb', line 1272

def size
  @size
end

Instance Method Details

#add(name, min, max) ⇒ Object

Parameters:

  • name (String)

    the name of the range

  • min (Integer, Float, nil)

    lower bound of the range (pass nil if there is no lower bound)

  • max (Integer, Float, nil)

    upper bound of the range (pass nil if there is no upper bound)



1284
1285
1286
# File 'lib/couchbase/search_options.rb', line 1284

def add(name, min, max)
  @ranges.append({name: name, min: min, max: max})
end

#to_json(*args) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



1289
1290
1291
# File 'lib/couchbase/search_options.rb', line 1289

def to_json(*args)
  {field: field, size: size, numeric_ranges: @ranges}.to_json(*args)
end