Sha256: 2c48c45bdfe0d57e1c48e96c905c8e5fb7d6e0a20a08b24c5fd5954d91ce23de

Contents?: true

Size: 579 Bytes

Versions: 1

Compression:

Stored size: 579 Bytes

Contents

module SQLTree::Node

  class Variable < Base

    attr_accessor :name

    def initialize(name)
      @name = name
    end

    def to_sql
      quote_var(@name)
    end

    def ==(other)
      other.name == self.name
    end

    def self.parse(tokens)
      if SQLTree::Token::Variable === tokens.peek
        if tokens.peek(2) == SQLTree::Token::DOT
          SQLTree::Node::Field.parse(tokens)
        else
          self.new(tokens.next.literal)
        end
      else
        raise SQLTree::Parser::UnexpectedToken.new(tokens.peek, :variable)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sql_tree-0.0.3 lib/sql_tree/node/variable.rb