Class: SQLTree::Node::Value
Instance Attribute Summary collapse
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(value) ⇒ Value
constructor
A new instance of Value.
- #to_sql ⇒ Object
Methods inherited from Base
[], #inspect, #quote_str, #quote_var
Constructor Details
#initialize(value) ⇒ Value
Returns a new instance of Value.
6 7 8 |
# File 'lib/sql_tree/node/value.rb', line 6 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
4 5 6 |
# File 'lib/sql_tree/node/value.rb', line 4 def value @value end |
Class Method Details
.parse(tokens) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/sql_tree/node/value.rb', line 22 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 |
Instance Method Details
#==(other) ⇒ Object
18 19 20 |
# File 'lib/sql_tree/node/value.rb', line 18 def ==(other) other.kind_of?(self.class) && other.value == self.value end |
#to_sql ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/sql_tree/node/value.rb', line 10 def to_sql case value when nil then 'NULL' when String then quote_str(@value) else @value.to_s end end |