Class: Groonga::ExpressionBuildable::ColumnValueExpressionBuilder
Instance Method Summary
collapse
#&, #|
Constructor Details
Returns a new instance of ColumnValueExpressionBuilder.
149
150
151
152
153
154
155
156
|
# File 'lib/groonga/expression-builder.rb', line 149
def initialize(column, options={})
super()
@table = options[:table] || column.table
@column = column
@column_name = options[:column_name] || @column.local_name
@range = options[:range] || @column.range
@name = options[:name]
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
259
260
261
262
263
264
265
266
267
|
# File 'lib/groonga/expression-builder.rb', line 259
def method_missing(name, *args, &block)
return super if block
return super unless args.empty?
if VALID_COLUMN_NAME_RE =~ name.to_s
RecordExpressionBuilder.new(@table, @name)["#{@column_name}.#{name}"]
else
super
end
end
|
Instance Method Details
213
214
215
|
# File 'lib/groonga/expression-builder.rb', line 213
def %(other)
ModExpressionBuilder.new(self, normalize(other))
end
|
205
206
207
|
# File 'lib/groonga/expression-builder.rb', line 205
def *(other)
StarExpressionBuilder.new(self, normalize(other))
end
|
197
198
199
|
# File 'lib/groonga/expression-builder.rb', line 197
def +(other)
PlusExpressionBuilder.new(self, normalize(other))
end
|
201
202
203
|
# File 'lib/groonga/expression-builder.rb', line 201
def -(other)
MinusExpressionBuilder.new(self, normalize(other))
end
|
209
210
211
|
# File 'lib/groonga/expression-builder.rb', line 209
def /(other)
SlashExpressionBuilder.new(self, normalize(other))
end
|
181
182
183
|
# File 'lib/groonga/expression-builder.rb', line 181
def <(other)
LessExpressionBuilder.new(self, normalize(other))
end
|
#=~(other) ⇒ Object
172
173
174
175
176
177
178
179
|
# File 'lib/groonga/expression-builder.rb', line 172
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(self, normalize(other))
end
|
#build(expression, variable) ⇒ Object
158
159
160
161
162
163
164
165
166
|
# File 'lib/groonga/expression-builder.rb', line 158
def build(expression, variable)
expression.append_object(variable)
if @column.is_a?(String)
expression.append_constant(@column)
else
expression.append_object(@column)
end
expression.append_operation(Groonga::Operation::GET_VALUE, 2)
end
|
#match(query, options = {}) ⇒ Object
217
218
219
220
221
222
|
# File 'lib/groonga/expression-builder.rb', line 217
def match(query, options={})
options = options.dup
options[:syntax] ||= :query
options[:default_column] = @column_name
SubExpressionBuilder.new(query, options)
end
|
#prefix_search(other) ⇒ Object
#similar_search(other) ⇒ Object
#suffix_search(other) ⇒ Object
236
237
238
239
240
241
242
243
244
|
# File 'lib/groonga/expression-builder.rb', line 236
def (other)
if @column_name == "_key"
TermExtractExpressionBuilder.new(self, normalize(other))
else
message = "term extraction supports _key column only: " +
"<#{@column_name}>"
raise ArgumentError, message
end
end
|