Class: Orchestrate::Search::RangeBuilder
- Inherits:
-
Object
- Object
- Orchestrate::Search::RangeBuilder
- 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
Instance Attribute Summary collapse
- #builder ⇒ AggregateBuilder readonly
-
#field_name ⇒ #to_s
readonly
The field to operate over.
-
#ranges ⇒ #to_s
readonly
The range sets.
Instance Method Summary collapse
- #above(x) ⇒ RangeBuilder
- #below(x) ⇒ RangeBuilder
- #between(x, y) ⇒ RangeBuilder
-
#initialize(builder, field_name) ⇒ RangeBuilder
constructor
Initialize a new RangeBuilder object.
-
#to_param ⇒ #to_s
Constructed aggregate string clause.
-
#to_s ⇒ Object
(also: #inspect)
Pretty-Printed string representation of the RangeBuilder object.
Constructor Details
#initialize(builder, field_name) ⇒ RangeBuilder
Initialize a new RangeBuilder object
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
#builder ⇒ AggregateBuilder (readonly)
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.
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.
173 174 175 |
# File 'lib/orchestrate/search/aggregate_builder.rb', line 173 def ranges @ranges end |
Instance Method Details
#above(x) ⇒ RangeBuilder
204 205 206 207 |
# File 'lib/orchestrate/search/aggregate_builder.rb', line 204 def above(x) @ranges << "#{x}~*:" self end |
#below(x) ⇒ RangeBuilder
197 198 199 200 |
# File 'lib/orchestrate/search/aggregate_builder.rb', line 197 def below(x) @ranges << "*~#{x}:" self end |
#between(x, y) ⇒ RangeBuilder
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.
191 192 193 |
# File 'lib/orchestrate/search/aggregate_builder.rb', line 191 def to_param "#{field_name}:range:#{ranges}" end |
#to_s ⇒ Object Also known as: inspect
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 |