Class: Orchestrate::Search::RangeBuilder

Inherits:
Object
  • Object
show all
Includes:
AggregateBuilderDelegator, QueryBuilderDelegator
Defined in:
lib/orchestrate/search/aggregate_builder.rb

Overview

Range Builder object for constructing range functions to be included in the aggregate param

Direct Known Subclasses

DistanceBuilder

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(builder, field_name) ⇒ RangeBuilder

Initialize a new RangeBuilder object

Parameters:



178
179
180
181
182
# File 'lib/orchestrate/search/aggregate_builder.rb', line 178

def initialize(builder, field_name)
  @builder = builder
  @field_name = field_name
  @ranges = ''
end

Instance Attribute Details

#builderAggregateBuilder (readonly)

Returns:



167
168
169
# File 'lib/orchestrate/search/aggregate_builder.rb', line 167

def builder
  @builder
end

#field_name#to_s (readonly)

Returns The field to operate over.

Returns:

  • (#to_s)

    The field to operate over



170
171
172
# File 'lib/orchestrate/search/aggregate_builder.rb', line 170

def field_name
  @field_name
end

#ranges#to_s (readonly)

Returns The range sets.

Returns:

  • (#to_s)

    The range sets



173
174
175
# File 'lib/orchestrate/search/aggregate_builder.rb', line 173

def ranges
  @ranges
end

Instance Method Details

#above(x) ⇒ RangeBuilder

Parameters:

  • x (Integer)

Returns:



204
205
206
207
# File 'lib/orchestrate/search/aggregate_builder.rb', line 204

def above(x)
  @ranges << "#{x}~*:"
  self
end

#below(x) ⇒ RangeBuilder

Parameters:

  • x (Integer)

Returns:



197
198
199
200
# File 'lib/orchestrate/search/aggregate_builder.rb', line 197

def below(x)
  @ranges << "*~#{x}:"
  self
end

#between(x, y) ⇒ RangeBuilder

Parameters:

  • x (Integer)
  • y (Integer)

Returns:



212
213
214
215
# File 'lib/orchestrate/search/aggregate_builder.rb', line 212

def between(x, y)
  @ranges << "#{x}~#{y}:"
  self
end

#to_param#to_s

Returns constructed aggregate string clause.

Returns:

  • (#to_s)

    constructed aggregate string clause



191
192
193
# File 'lib/orchestrate/search/aggregate_builder.rb', line 191

def to_param
  "#{field_name}:range:#{ranges}"
end

#to_sObject Also known as: inspect

Returns Pretty-Printed string representation of the RangeBuilder object.

Returns:

  • Pretty-Printed string representation of the RangeBuilder object



185
186
187
# File 'lib/orchestrate/search/aggregate_builder.rb', line 185

def to_s
  "#<Orchestrate::Search::RangeBuilder collection=#{collection.name} field_name=#{field_name} ranges=#{ranges}>"
end