Class: Rgviz::Query
- Inherits:
-
Object
- Object
- Rgviz::Query
- Defined in:
- lib/rgviz/nodes.rb
Instance Attribute Summary collapse
-
#formats ⇒ Object
Returns the value of attribute formats.
-
#group_by ⇒ Object
Returns the value of attribute group_by.
-
#labels ⇒ Object
Returns the value of attribute labels.
-
#limit ⇒ Object
Returns the value of attribute limit.
-
#offset ⇒ Object
Returns the value of attribute offset.
-
#options ⇒ Object
Returns the value of attribute options.
-
#order_by ⇒ Object
Returns the value of attribute order_by.
-
#pivot ⇒ Object
Returns the value of attribute pivot.
-
#select ⇒ Object
Returns the value of attribute select.
-
#where ⇒ Object
Returns the value of attribute where.
Instance Method Summary collapse
Instance Attribute Details
#formats ⇒ Object
Returns the value of attribute formats.
11 12 13 |
# File 'lib/rgviz/nodes.rb', line 11 def formats @formats end |
#group_by ⇒ Object
Returns the value of attribute group_by.
5 6 7 |
# File 'lib/rgviz/nodes.rb', line 5 def group_by @group_by end |
#labels ⇒ Object
Returns the value of attribute labels.
10 11 12 |
# File 'lib/rgviz/nodes.rb', line 10 def labels @labels end |
#limit ⇒ Object
Returns the value of attribute limit.
8 9 10 |
# File 'lib/rgviz/nodes.rb', line 8 def limit @limit end |
#offset ⇒ Object
Returns the value of attribute offset.
9 10 11 |
# File 'lib/rgviz/nodes.rb', line 9 def offset @offset end |
#options ⇒ Object
Returns the value of attribute options.
12 13 14 |
# File 'lib/rgviz/nodes.rb', line 12 def @options end |
#order_by ⇒ Object
Returns the value of attribute order_by.
7 8 9 |
# File 'lib/rgviz/nodes.rb', line 7 def order_by @order_by end |
#pivot ⇒ Object
Returns the value of attribute pivot.
6 7 8 |
# File 'lib/rgviz/nodes.rb', line 6 def pivot @pivot end |
#select ⇒ Object
Returns the value of attribute select.
3 4 5 |
# File 'lib/rgviz/nodes.rb', line 3 def select @select end |
#where ⇒ Object
Returns the value of attribute where.
4 5 6 |
# File 'lib/rgviz/nodes.rb', line 4 def where @where end |
Instance Method Details
#accept(visitor) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rgviz/nodes.rb', line 18 def accept(visitor) if visitor.visit_query self select.accept visitor if select where.accept visitor if where group_by.accept visitor if group_by pivot.accept visitor if pivot order_by.accept visitor if order_by labels.each{|x| x.accept visitor} if labels formats.each{|x| x.accept visitor} if formats end visitor.end_visit_query self end |
#select? ⇒ Boolean
14 15 16 |
# File 'lib/rgviz/nodes.rb', line 14 def select? @select && @select.columns && @select.columns.length > 0 end |
#to_s ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/rgviz/nodes.rb', line 31 def to_s str = '' if select if select.columns.empty? str << "select * " else str << "select #{select.to_s} " end end str << "where #{where} " if where str << "group by #{group_by} " if group_by str << "pivot #{pivot} " if pivot str << "order by #{order_by} " if order_by str << "limit #{limit} " if limit str << "offset #{offset} " if offset str << "label #{labels.map(&:to_s).join(', ')} " if labels str << "format #{formats.map(&:to_s).join(', ')} " if formats str << "options #{} " if str.strip end |