Class: Couchbase::SearchFacet::SearchFacetDateRange
- Inherits:
-
Object
- Object
- Couchbase::SearchFacet::SearchFacetDateRange
- Defined in:
- lib/couchbase/search_options.rb
Constant Summary collapse
- DATE_FORMAT_RFC3339 =
"%Y-%m-%dT%H:%M:%S%:z"
Instance Attribute Summary collapse
- #field ⇒ String readonly
- #size ⇒ Integer
Instance Method Summary collapse
- #add(name, start_time, end_time) ⇒ Object
-
#initialize(field) {|_self| ... } ⇒ SearchFacetDateRange
constructor
A new instance of SearchFacetDateRange.
- #to_json(*args) ⇒ Object private
Constructor Details
#initialize(field) {|_self| ... } ⇒ SearchFacetDateRange
Returns a new instance of SearchFacetDateRange.
1330 1331 1332 1333 1334 1335 |
# File 'lib/couchbase/search_options.rb', line 1330 def initialize(field) super() @field = field @ranges = [] yield self if block_given? end |
Instance Attribute Details
#field ⇒ String (readonly)
1324 1325 1326 |
# File 'lib/couchbase/search_options.rb', line 1324 def field @field end |
#size ⇒ Integer
1327 1328 1329 |
# File 'lib/couchbase/search_options.rb', line 1327 def size @size end |
Instance Method Details
#add(name, start_time, end_time) ⇒ Object
1342 1343 1344 1345 1346 |
# File 'lib/couchbase/search_options.rb', line 1342 def add(name, start_time, end_time) start_time = start_time.strftime(DATE_FORMAT_RFC3339) if start_time.respond_to?(:strftime) end_time = end_time.strftime(DATE_FORMAT_RFC3339) if end_time.respond_to?(:strftime) @ranges.append({name: name, start: start_time, end: end_time}) 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.
1349 1350 1351 |
# File 'lib/couchbase/search_options.rb', line 1349 def to_json(*args) {field: field, size: size, date_ranges: @ranges}.to_json(*args) end |