Sha256: ef15c775e1e49a0895f1b3cde9694a37f3313f7f3676daa87f4e55c09c1a1fac
Contents?: true
Size: 722 Bytes
Versions: 2
Compression:
Stored size: 722 Bytes
Contents
module SQLTree::Node class Value < Base attr_accessor :value def initialize(value) @value = value end def to_sql case value when nil then 'NULL' when String then quote_str(@value) else @value.to_s end end def ==(other) other.kind_of?(self.class) && other.value == self.value end def self.parse(tokens) case tokens.next when SQLTree::Token::String, SQLTree::Token::Number SQLTree::Node::Value.new(tokens.current.literal) when SQLTree::Token::NULL SQLTree::Node::Value.new(nil) else raise SQLTree::Parser::UnexpectedToken.new(tokens.current, :literal) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sql_tree-0.1.0 | lib/sql_tree/node/value.rb |
sql_tree-0.0.3 | lib/sql_tree/node/value.rb |