Class: CreateTableFuncFilter
- Inherits:
-
Ripper::Filter
- Object
- Ripper::Filter
- CreateTableFuncFilter
show all
- Defined in:
- lib/func_filter.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#add_tok(tok) ⇒ Object
-
#initialize(src, fclass) ⇒ CreateTableFuncFilter
constructor
A new instance of CreateTableFuncFilter.
-
#on_default(event, tok, f) ⇒ Object
-
#on_do_block(tok, f) ⇒ Object
-
#on_float(tok, f) ⇒ Object
-
#on_ident(tok, f) ⇒ Object
-
#on_int(tok, f) ⇒ Object
-
#on_kw(tok, f) ⇒ Object
-
#on_lbrase(tok, f) ⇒ Object
-
#on_nl(tok, f) ⇒ Object
-
#on_rbrase(tok, f) ⇒ Object
-
#on_tstring_beg(tok, f) ⇒ Object
-
#on_tstring_content(tok, f) ⇒ Object
-
#on_tstring_end(tok, f) ⇒ Object
Constructor Details
Returns a new instance of CreateTableFuncFilter.
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/func_filter.rb', line 44
def initialize(src, fclass)
super src
@fclass = fclass
@func_str = ''
@is_func_option = true
@func_option_str = ''
@is_do = false
@is_column_option = false
@column_option_str = Array.new
end
|
Instance Attribute Details
#column_option_str ⇒ Object
Returns the value of attribute column_option_str.
42
43
44
|
# File 'lib/func_filter.rb', line 42
def column_option_str
@column_option_str
end
|
#fclass ⇒ Object
Returns the value of attribute fclass.
42
43
44
|
# File 'lib/func_filter.rb', line 42
def fclass
@fclass
end
|
#func_option_str ⇒ Object
Returns the value of attribute func_option_str.
42
43
44
|
# File 'lib/func_filter.rb', line 42
def func_option_str
@func_option_str
end
|
#func_str ⇒ Object
Returns the value of attribute func_str.
42
43
44
|
# File 'lib/func_filter.rb', line 42
def func_str
@func_str
end
|
Instance Method Details
#add_tok(tok) ⇒ Object
56
57
58
59
60
61
62
63
64
|
# File 'lib/func_filter.rb', line 56
def add_tok(tok)
if @is_column_option
@column_option_str[-1] += tok
elsif @is_func_option
@func_option_str += tok
elsif @is_func
@func_str += tok
end
end
|
#on_default(event, tok, f) ⇒ Object
66
67
68
|
# File 'lib/func_filter.rb', line 66
def on_default(event, tok, f)
add_tok tok
end
|
#on_do_block(tok, f) ⇒ Object
120
121
122
123
|
# File 'lib/func_filter.rb', line 120
def on_do_block(tok, f)
@is_do = true
add_tok tok
end
|
#on_float(tok, f) ⇒ Object
170
171
172
173
174
175
176
177
178
179
|
# File 'lib/func_filter.rb', line 170
def on_float(tok, f)
if @is_column_option && !@column_option.nil?
@fclass.columns.last.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/func_filter.rb', line 87
def on_ident(tok, f)
if tok == 't'
@is_column = true
elsif @is_column
if (tok != 'timestamps') && (tok != 'attachment')
@column_type = tok
@is_column_type = true
@column_option_str << ''
else
@fclass.add_column(tok)
@is_column_type = false
end
@is_column = false
elsif @is_column_type
@fclass.add_column(@column_type, tok)
@is_column_type = false
@is_column_option = true
@column_type = nil
elsif @is_column_option
@column_option = tok
elsif @is_func_option
@func_option = tok
end
add_tok tok
end
|
#on_int(tok, f) ⇒ Object
159
160
161
162
163
164
165
166
167
168
|
# File 'lib/func_filter.rb', line 159
def on_int(tok, f)
if @is_column_option && !@column_option.nil?
@fclass.columns.last.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/func_filter.rb', line 70
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.columns.last.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_lbrase(tok, f) ⇒ Object
125
126
127
128
|
# File 'lib/func_filter.rb', line 125
def on_lbrase(tok, f)
@is_do = true
add_tok tok
end
|
#on_nl(tok, f) ⇒ Object
113
114
115
116
117
118
|
# File 'lib/func_filter.rb', line 113
def on_nl(tok, f)
@is_func_option = false
@is_column = false
@is_column_option = false
add_tok tok
end
|
#on_rbrase(tok, f) ⇒ Object
130
131
132
133
|
# File 'lib/func_filter.rb', line 130
def on_rbrase(tok, f)
@is_do = false
add_tok tok
end
|
#on_tstring_beg(tok, f) ⇒ Object
147
148
149
150
|
# File 'lib/func_filter.rb', line 147
def on_tstring_beg(tok, f)
@is_tstring_content = false
add_tok tok
end
|
#on_tstring_content(tok, f) ⇒ Object
135
136
137
138
139
140
141
142
143
144
145
|
# File 'lib/func_filter.rb', line 135
def on_tstring_content(tok, f)
if @is_column_option && !@column_option.nil?
@fclass.columns.last.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
|
#on_tstring_end(tok, f) ⇒ Object
152
153
154
155
156
157
|
# File 'lib/func_filter.rb', line 152
def on_tstring_end(tok, f)
if !@is_tstring_content
on_tstring_content("", f)
end
add_tok tok
end
|