Class: SQLTree::Node::FunctionExpression
- Inherits:
-
Expression
- Object
- Base
- Expression
- SQLTree::Node::FunctionExpression
- Defined in:
- lib/sql_tree/node/expression.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
Returns the value of attribute arguments.
-
#function ⇒ Object
Returns the value of attribute function.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(function, arguments = []) ⇒ FunctionExpression
constructor
A new instance of FunctionExpression.
- #to_sql ⇒ Object
Methods inherited from Expression
Methods inherited from Base
[], #inspect, #quote_str, #quote_var
Constructor Details
#initialize(function, arguments = []) ⇒ FunctionExpression
Returns a new instance of FunctionExpression.
162 163 164 165 |
# File 'lib/sql_tree/node/expression.rb', line 162 def initialize(function, arguments = []) @function = function @arguments = arguments end |
Instance Attribute Details
#arguments ⇒ Object
Returns the value of attribute arguments.
160 161 162 |
# File 'lib/sql_tree/node/expression.rb', line 160 def arguments @arguments end |
#function ⇒ Object
Returns the value of attribute function.
160 161 162 |
# File 'lib/sql_tree/node/expression.rb', line 160 def function @function end |
Class Method Details
.parse(tokens) ⇒ Object
171 172 173 174 175 176 177 178 179 180 |
# File 'lib/sql_tree/node/expression.rb', line 171 def self.parse(tokens) expr = self.new(tokens.next.literal) tokens.consume(SQLTree::Token::LPAREN) until tokens.peek == SQLTree::Token::RPAREN expr.arguments << SQLTree::Node::Expression.parse(tokens) tokens.consume(SQLTree::Token::COMMA) if tokens.peek == SQLTree::Token::COMMA end tokens.consume(SQLTree::Token::RPAREN) return expr end |
Instance Method Details
#to_sql ⇒ Object
167 168 169 |
# File 'lib/sql_tree/node/expression.rb', line 167 def to_sql "#{@function}(" + @arguments.map { |e| e.to_sql }.join(', ') + ")" end |