Class: Ronin::Code::SQL::JoinClause
- Defined in:
- lib/ronin/code/sql/join_clause.rb
Instance Attribute Summary collapse
-
#direction ⇒ Object
Direction of the join.
-
#natural ⇒ Object
Whether the join is natural or not.
-
#side ⇒ Object
Side of the join.
-
#table ⇒ Object
Table to join with.
Instance Method Summary collapse
- #cross ⇒ Object
- #emit ⇒ Object
- #full ⇒ Object
-
#initialize(table, options = {}) ⇒ JoinClause
constructor
A new instance of JoinClause.
- #inner ⇒ Object
- #left ⇒ Object
- #outer ⇒ Object
- #right ⇒ Object
Constructor Details
#initialize(table, options = {}) ⇒ JoinClause
Returns a new instance of JoinClause.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/ronin/code/sql/join_clause.rb', line 41 def initialize(table,={}) @table = table @natural = [:natural] if [:left] @direction = :left elsif [:right] @direction = :right elsif [:full] @direction = :full end if [:inner] @side = :inner elsif [:outer] @side = :outer elsif [:cross] @side = :cross end end |
Instance Attribute Details
#direction ⇒ Object
Direction of the join
36 37 38 |
# File 'lib/ronin/code/sql/join_clause.rb', line 36 def direction @direction end |
#natural ⇒ Object
Whether the join is natural or not
33 34 35 |
# File 'lib/ronin/code/sql/join_clause.rb', line 33 def natural @natural end |
#side ⇒ Object
Side of the join
39 40 41 |
# File 'lib/ronin/code/sql/join_clause.rb', line 39 def side @side end |
#table ⇒ Object
Table to join with
30 31 32 |
# File 'lib/ronin/code/sql/join_clause.rb', line 30 def table @table end |
Instance Method Details
#cross ⇒ Object
87 88 89 90 |
# File 'lib/ronin/code/sql/join_clause.rb', line 87 def cross @side = :cross return self end |
#emit ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/ronin/code/sql/join_clause.rb', line 92 def emit tokens = [] tokens += emit_token('NATURAL') if @natural case @direction when :left, 'left' tokens += emit_token('LEFT') when :right, 'right' tokens += emit_token('RIGHT') when :full, 'full' tokens += emit_token('FULL') end case @side when :inner, 'inner' tokens += emit_token('INNER') when :outer, 'outer' tokens += emit_token('OUTER') when :cross, 'cross' tokens += emit_token('CROSS') end tokens += emit_token('JOIN') return tokens + emit_value(@table) end |
#full ⇒ Object
72 73 74 75 |
# File 'lib/ronin/code/sql/join_clause.rb', line 72 def full @direction = :full return self end |
#inner ⇒ Object
77 78 79 80 |
# File 'lib/ronin/code/sql/join_clause.rb', line 77 def inner @side = :inner return self end |
#left ⇒ Object
62 63 64 65 |
# File 'lib/ronin/code/sql/join_clause.rb', line 62 def left @direction = :left return self end |
#outer ⇒ Object
82 83 84 85 |
# File 'lib/ronin/code/sql/join_clause.rb', line 82 def outer @side = :outer return self end |
#right ⇒ Object
67 68 69 70 |
# File 'lib/ronin/code/sql/join_clause.rb', line 67 def right @direction = :right return self end |