Class: AddColumnFuncFilter

Inherits:
CreateTableFuncFilter show all
Defined in:
lib/func_filter.rb

Direct Known Subclasses

ChangeColumnFuncFilter

Instance Attribute Summary

Attributes inherited from CreateTableFuncFilter

#column_option_str, #fclass, #func_option_str, #func_str

Instance Method Summary collapse

Methods inherited from CreateTableFuncFilter

#on_default, #on_do_block, #on_lbrase, #on_nl, #on_rbrase, #on_tstring_beg, #on_tstring_end

Constructor Details

#initialize(src, fclass) ⇒ AddColumnFuncFilter

Returns a new instance of AddColumnFuncFilter.



204
205
206
207
208
209
210
211
212
# File 'lib/func_filter.rb', line 204

def initialize(src, fclass)
  super src, fclass

  @is_func_name = true
  @is_table_name = false
  @is_column = false
  @is_column_type = false
  @column_option_str = ''
end

Instance Method Details

#add_tok(tok) ⇒ Object



214
215
216
217
218
219
220
221
222
# File 'lib/func_filter.rb', line 214

def add_tok(tok)
  if @is_column_option
    @column_option_str += tok
  elsif @is_func_option
    @func_option_str += tok
  elsif @is_func
    @func_str += tok
  end
end

#on_float(tok, f) ⇒ Object



285
286
287
288
289
290
291
292
293
294
# File 'lib/func_filter.rb', line 285

def on_float(tok, f)
  if @is_column_option && !@column_option.nil?
    @fclass.column.set_option(@column_option, tok)
    @column_option = nil
  elsif @is_func_option && !@func_option.nil?
    @fclass.option.set_option(@func_option, tok)
    @func_option = nil
  end
  add_tok tok
end

#on_ident(tok, f) ⇒ Object



241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
# File 'lib/func_filter.rb', line 241

def on_ident(tok, f)
  if @is_func_name
    @is_func_name = false
    @is_table_name = true
  elsif @is_table_name
    @is_table_name = false
    @is_column = true
  elsif @is_column
    @column_name = tok
    @is_column = false
    @is_column_type = true
  elsif @is_column_type
    @fclass.add_column(tok, @column_name)
    @is_column_type = false
    @is_column_option = true
  elsif @is_column_option
    @column_option = tok
  end
  add_tok tok
end

#on_int(tok, f) ⇒ Object



274
275
276
277
278
279
280
281
282
283
# File 'lib/func_filter.rb', line 274

def on_int(tok, f)
  if @is_column_option && !@column_option.nil?
    @fclass.column.set_option(@column_option, tok)
    @column_option = nil
  elsif @is_func_option && !@func_option.nil?
    @fclass.option.set_option(@func_option, tok)
    @func_option = nil
  end
  add_tok tok
end

#on_kw(tok, f) ⇒ Object



224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/func_filter.rb', line 224

def on_kw(tok, f)
  if tok == 'end'
    if @is_do
      @is_do = false
    end
  elsif tok == 'true' || tok == 'false'
    if @is_column_option && !@column_option.nil?
      @fclass.column.set_option(@column_option, "'" + tok + "'")
      @column_option = nil
    elsif @is_func_option && !@func_option.nil?
      @fclass.option.set_option(@func_option, tok)
      @func_option = nil
    end
  end
  add_tok tok
end

#on_tstring_content(tok, f) ⇒ Object



262
263
264
265
266
267
268
269
270
271
272
# File 'lib/func_filter.rb', line 262

def on_tstring_content(tok, f)
  if @is_column_option && !@column_option.nil?
    @fclass.column.set_option(@column_option, "'" + tok + "'")
    @column_option = nil
  elsif @is_func_option && !@func_option.nil?
    @fclass.option.set_option(@func_option, "'" + tok + "'")
    @func_option = nil
  end
  @is_tstring_content = true
  add_tok tok
end