Class: Groonga::ExpressionBuildable::ColumnValueExpressionBuilder
Instance Method Summary
collapse
#&, #|
Constructor Details
Returns a new instance of ColumnValueExpressionBuilder.
147
148
149
150
151
152
153
154
|
# File 'lib/groonga/expression-builder.rb', line 147
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
257
258
259
260
261
262
263
264
265
|
# File 'lib/groonga/expression-builder.rb', line 257
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
211
212
213
|
# File 'lib/groonga/expression-builder.rb', line 211
def %(other)
ModExpressionBuilder.new(self, normalize(other))
end
|
203
204
205
|
# File 'lib/groonga/expression-builder.rb', line 203
def *(other)
StarExpressionBuilder.new(self, normalize(other))
end
|
195
196
197
|
# File 'lib/groonga/expression-builder.rb', line 195
def +(other)
PlusExpressionBuilder.new(self, normalize(other))
end
|
199
200
201
|
# File 'lib/groonga/expression-builder.rb', line 199
def -(other)
MinusExpressionBuilder.new(self, normalize(other))
end
|
207
208
209
|
# File 'lib/groonga/expression-builder.rb', line 207
def /(other)
SlashExpressionBuilder.new(self, normalize(other))
end
|
179
180
181
|
# File 'lib/groonga/expression-builder.rb', line 179
def <(other)
LessExpressionBuilder.new(self, normalize(other))
end
|
#=~(other) ⇒ Object
170
171
172
173
174
175
176
177
|
# File 'lib/groonga/expression-builder.rb', line 170
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
156
157
158
159
160
161
162
163
164
|
# File 'lib/groonga/expression-builder.rb', line 156
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
215
216
217
218
219
220
|
# File 'lib/groonga/expression-builder.rb', line 215
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
234
235
236
237
238
239
240
241
242
|
# File 'lib/groonga/expression-builder.rb', line 234
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
|