Class: SQLTree::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/sql_tree/token.rb

Direct Known Subclasses

Keyword, Operator, Value

Defined Under Namespace

Classes: Keyword, Number, Operator, String, Value, Variable

Constant Summary collapse

LPAREN =
Class.new(SQLTree::Token).new('(')
RPAREN =
Class.new(SQLTree::Token).new(')')
DOT =
Class.new(SQLTree::Token).new('.')
COMMA =
Class.new(SQLTree::Token).new(',')
KEYWORDS =
%w{select from where group having order distinct left right inner outer join and or not as}
ARITHMETHIC_OPERATORS =
{ '+' => :plus, '-' => :minus, '*' => :multiply, '/' => :divide, '%' => :modulo }
LOGICAL_OPERATORS =
{ '=' => :eq, '!=' => :ne, '<>' => :ne, '>' => :gt, '<' => :lt, '>=' => :gte, '<=' => :lte }
OPERATORS =
ARITHMETHIC_OPERATORS.merge(LOGICAL_OPERATORS)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(literal) ⇒ Token

Returns a new instance of Token.



5
6
7
# File 'lib/sql_tree/token.rb', line 5

def initialize(literal)
  @literal = literal
end

Instance Attribute Details

#literalObject

Returns the value of attribute literal.



3
4
5
# File 'lib/sql_tree/token.rb', line 3

def literal
  @literal
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



9
10
11
# File 'lib/sql_tree/token.rb', line 9

def ==(other)
  other.class == self.class && @literal == other.literal
end

#inspectObject



15
16
17
# File 'lib/sql_tree/token.rb', line 15

def inspect
  literal
end