Class: Groonga::Client::Request::Select::Filter
- Inherits:
-
Object
- Object
- Groonga::Client::Request::Select::Filter
- Defined in:
- lib/groonga/client/request/select.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#between(*args) ⇒ Groonga::Client::Request::Select
Adds a
between
condition then returns a newselect
request object. -
#geo_in_circle(column_name_or_point, center, radius_or_point, approximate_type = "rectangle") ⇒ Object
Adds a
geo_in_circle
condition then returns a newselect
request object. -
#geo_in_rectangle(column_name_or_point, top_left, bottom_right) ⇒ Object
Adds a
geo_in_rectangle
condition then return a newselect
request object. -
#in_values(column_name, *values) ⇒ Groonga::Client::Request::Select
Adds a
in_values
condition then returns a newselect
request object. -
#initialize(request) ⇒ Filter
constructor
A new instance of Filter.
Constructor Details
#initialize(request) ⇒ Filter
Returns a new instance of Filter.
333 334 335 |
# File 'lib/groonga/client/request/select.rb', line 333 def initialize(request) @request = request end |
Class Method Details
.column_namify(column_name, ith, signature) ⇒ Object
322 323 324 325 326 327 328 329 330 |
# File 'lib/groonga/client/request/select.rb', line 322 def column_namify(column_name, ith, signature) return column_name unless column_name.is_a?(String) = "column name (the #{ith} argument) of #{signature} " << "should be Symbol: #{column_name.inspect}: " << caller(2, 1)[0] warn() column_name.to_sym end |
Instance Method Details
#between(column_name, min, max, min_border: "include", max_border: "include") ⇒ Groonga::Client::Request::Select #between(column_name, min, min_border, max, max_border) ⇒ Groonga::Client::Request::Select
Adds a between
condition then returns a new select
request object.
505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 |
# File 'lib/groonga/client/request/select.rb', line 505 def between(*args) n_args = args.size case n_args when 3 column_name, min, max = args min_border = "include" max_border = "include" when 4 column_name, min, max, = args min_border = [:min_border] || "include" max_border = [:max_border] || "include" when 5 column_name, min, min_border, max, max_border = args else = "wrong number of arguments (given #{n_args}, expected 3..5)" raise ArgumentError, end # TODO: Accept not only column name but also literal as # the first argument. column_name = self.class.column_namify(column_name, "first", "#{self.class}\##{__method__}") expression = +"between(%{column_name}" expression << ", %{min}" expression << ", %{min_border}" expression << ", %{max}" expression << ", %{max_border}" expression << ")" @request.filter(expression, column_name: column_name, min: min, min_border: min_border, max: max, max_border: max_border) end |
#geo_in_circle(column_name, center, radius, approximate_type = "rectangle") ⇒ Groonga::Client::Request::Select #geo_in_circle(point, center, radius, approximate_type = "rectangle") ⇒ Groonga::Client::Request::Select
Adds a geo_in_circle
condition then returns a new select
request object.
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 |
# File 'lib/groonga/client/request/select.rb', line 439 def geo_in_circle(column_name_or_point, center, radius_or_point, approximate_type="rectangle") expression = +"geo_in_circle(%{column_name_or_point}" expression << ", %{center}" expression << ", %{radius_or_point}" expression << ", %{approximate_type}" expression << ")" @request.filter(expression, column_name_or_point: column_name_or_point, center: center, radius_or_point: radius_or_point, approximate_type: approximate_type) end |
#geo_in_rectangle(column_name, top_left, bottom_right) ⇒ Groonga::Client::Request::Select #geo_in_rectangle(point, top_left, bottom_right) ⇒ Groonga::Client::Request::Select
Adds a geo_in_rectangle
condition then return a new select
request object.
378 379 380 381 382 383 384 385 386 387 388 |
# File 'lib/groonga/client/request/select.rb', line 378 def geo_in_rectangle(column_name_or_point, top_left, bottom_right) expression = +"geo_in_rectangle(%{column_name_or_point}" expression << ", %{top_left}" expression << ", %{bottom_right}" expression << ")" @request.filter(expression, column_name_or_point: column_name_or_point, top_left: top_left, bottom_right: bottom_right) end |
#in_values(column_name, *values) ⇒ Groonga::Client::Request::Select
Adds a in_values
condition then returns a new select
request object.
571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 |
# File 'lib/groonga/client/request/select.rb', line 571 def in_values(column_name, *values) return @request if values.empty? # TODO: Accept not only column name but also literal as # the first argument. column_name = self.class.column_namify(column_name, "first", "#{self.class}\##{__method__}") expression_values = {column_name: column_name} expression = +"in_values(%{column_name}" values.each_with_index do |value, i| expression << ", %{value#{i}}" expression_values[:"value#{i}"] = value end expression << ")" @request.filter(expression, expression_values) end |