Class: Groonga::ColumnExpressionBuilder

Inherits:
Object
  • Object
show all
Includes:
ExpressionBuildable
Defined in:
lib/groonga/expression-builder.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes included from ExpressionBuildable

#allow_column, #allow_pragma, #allow_update, #default_column, #query, #syntax, #table

Instance Method Summary collapse

Methods included from ExpressionBuildable

#&, #build, #|

Constructor Details

#initialize(column, name, query, options = {}) ⇒ ColumnExpressionBuilder

Returns a new instance of ColumnExpressionBuilder.



231
232
233
234
235
236
237
238
239
# File 'lib/groonga/expression-builder.rb', line 231

def initialize(column, name, query, options={})
  super()
  @table = options[:table] || column.table
  @default_column = column
  @column_name = options[:column_name] || @default_column.local_name
  @range = @default_column.range
  @name = name
  @query = query
end

Instance Method Details

#<(other) ⇒ Object



253
254
255
# File 'lib/groonga/expression-builder.rb', line 253

def <(other)
  LessExpressionBuilder.new(@default_column, normalize(other))
end

#<=(other) ⇒ Object



257
258
259
# File 'lib/groonga/expression-builder.rb', line 257

def <=(other)
  LessEqualExpressionBuilder.new(@default_column, normalize(other))
end

#==(other) ⇒ Object



241
242
243
# File 'lib/groonga/expression-builder.rb', line 241

def ==(other)
  EqualExpressionBuilder.new(@default_column, normalize(other))
end

#=~(other) ⇒ Object



245
246
247
248
249
250
251
# File 'lib/groonga/expression-builder.rb', line 245

def =~(other)
  if other.nil?
    full_column_name = "#{@table.name}.#{@column_name}"
    raise ArgumentError, "match word should not be nil: #{full_column_name}"
  end
  MatchExpressionBuilder.new(@default_column, normalize(other))
end

#>(other) ⇒ Object



261
262
263
# File 'lib/groonga/expression-builder.rb', line 261

def >(other)
  GreaterExpressionBuilder.new(@default_column, normalize(other))
end

#>=(other) ⇒ Object



265
266
267
# File 'lib/groonga/expression-builder.rb', line 265

def >=(other)
  GreaterEqualExpressionBuilder.new(@default_column, normalize(other))
end

#match(query, options = {}) ⇒ Object



269
270
271
272
273
274
# File 'lib/groonga/expression-builder.rb', line 269

def match(query, options={})
  options = options.dup
  options[:syntax] ||= :query
  options[:default_column] = @column_name
  SubExpressionBuilder.new(query, options)
end