Class: AddIndexFuncFilter

Inherits:
Ripper::Filter
  • Object
show all
Defined in:
lib/func_filter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(src, fclass) ⇒ AddIndexFuncFilter

Returns a new instance of AddIndexFuncFilter.



404
405
406
407
408
409
410
411
412
# File 'lib/func_filter.rb', line 404

def initialize(src, fclass)
  super src

  @fclass = fclass
  @func_str = ''
  @is_columns = false
  @columns = ''
  @is_index_option = false
end

Instance Attribute Details

#fclassObject

Returns the value of attribute fclass.



402
403
404
# File 'lib/func_filter.rb', line 402

def fclass
  @fclass
end

#func_strObject

Returns the value of attribute func_str.



402
403
404
# File 'lib/func_filter.rb', line 402

def func_str
  @func_str
end

Instance Method Details

#add_tok(tok) ⇒ Object



414
415
416
417
418
419
# File 'lib/func_filter.rb', line 414

def add_tok(tok)
  if @is_columns
    @columns += tok
  end
  @func_str += tok
end

#on_default(event, tok, f) ⇒ Object



421
422
423
# File 'lib/func_filter.rb', line 421

def on_default(event, tok, f)
  add_tok tok
end

#on_int(tok, f) ⇒ Object



439
440
441
442
443
444
# File 'lib/func_filter.rb', line 439

def on_int(tok, f)
  if @is_index_option
    @fclass.option.set_option('length', tok)
  end
  add_tok tok
end

#on_kw(tok, f) ⇒ Object



425
426
427
428
429
430
# File 'lib/func_filter.rb', line 425

def on_kw(tok, f)
  if @is_index_option && (tok == 'true' || tok == 'false')
    @fclass.option.set_option('unique', tok)
  end
  add_tok tok
end

#on_lbracket(tok, f) ⇒ Object



446
447
448
449
# File 'lib/func_filter.rb', line 446

def on_lbracket(tok, f)
  @is_columns = true
  add_tok tok
end

#on_rbracket(tok, f) ⇒ Object



451
452
453
454
455
456
# File 'lib/func_filter.rb', line 451

def on_rbracket(tok, f)
  add_tok tok
  @fclass.columns = @columns
  @is_index_option = true;
  @is_columns = false
end

#on_tstring_content(tok, f) ⇒ Object



432
433
434
435
436
437
# File 'lib/func_filter.rb', line 432

def on_tstring_content(tok, f)
  if @is_index_option
    @fclass.option.set_option('name', "'#{tok}'")
  end
  add_tok tok
end