Class: OracleSqlParser::Ast::Array
- Inherits:
-
Base
show all
- Includes:
- Enumerable
- Defined in:
- lib/oracle-sql-parser/ast/array.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#==, #ast, deep_dup, #deep_dup, find_different_value, #initialize_copy, #map_ast
#to_parameterized, #to_parameternized
Constructor Details
#initialize(*args) ⇒ Array
Returns a new instance of Array.
28
29
30
|
# File 'lib/oracle-sql-parser/ast/array.rb', line 28
def initialize(*args)
@ast = args
end
|
Class Method Details
.[](*values) ⇒ Object
15
16
17
|
# File 'lib/oracle-sql-parser/ast/array.rb', line 15
def self.[](*values)
self.new(*values)
end
|
Instance Method Details
#[](index) ⇒ Object
11
12
13
|
# File 'lib/oracle-sql-parser/ast/array.rb', line 11
def [](index)
@ast[index]
end
|
#each(&block) ⇒ Object
7
8
9
|
# File 'lib/oracle-sql-parser/ast/array.rb', line 7
def each(&block)
@ast.each(&block)
end
|
48
49
50
51
52
|
# File 'lib/oracle-sql-parser/ast/array.rb', line 48
def inspect
"#<#{self.class.name} [\n" +
@ast.map{|v| "#{v.inspect}"}.join(",\n").gsub(/^/, ' ') +
"\n]>\n"
end
|
#map_ast!(&block) ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'lib/oracle-sql-parser/ast/array.rb', line 19
def map_ast!(&block)
@ast = @ast.map do |v|
if v.is_a? OracleSqlParser::Ast::Base
v.map_ast!(&block)
end
block.call(v)
end
end
|
#remove_nil_values! ⇒ Object
42
43
44
45
46
|
# File 'lib/oracle-sql-parser/ast/array.rb', line 42
def remove_nil_values!
@ast.delete_if{|v| v.nil?}
@ast.each {|v| v.remove_nil_values! if v.respond_to? :remove_nil_values!}
self
end
|
#to_sql(options = {:separator => ' '}) ⇒ Object
32
33
34
35
36
37
38
39
40
|
# File 'lib/oracle-sql-parser/ast/array.rb', line 32
def to_sql(options = {:separator => ' '})
@ast.map do |v|
if v.respond_to? :to_sql
v.to_sql
else
v.to_s
end
end.compact.join(options[:separator])
end
|