Class: OrientDB::SQL::ConditionExpression
- Inherits:
-
Object
- Object
- OrientDB::SQL::ConditionExpression
- Includes:
- Comparable
- Defined in:
- lib/orientdb/sql/common.rb
Instance Attribute Summary collapse
-
#conditions ⇒ Object
readonly
Returns the value of attribute conditions.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #add(*conds) ⇒ Object
- #clear ⇒ Object
- #conditions_str ⇒ Object
-
#initialize(type) ⇒ ConditionExpression
constructor
A new instance of ConditionExpression.
- #parens_conditions_str ⇒ Object
- #to_s ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(type) ⇒ ConditionExpression
Returns a new instance of ConditionExpression.
200 201 202 203 |
# File 'lib/orientdb/sql/common.rb', line 200 def initialize(type) @type = type @conditions = [] end |
Instance Attribute Details
#conditions ⇒ Object (readonly)
Returns the value of attribute conditions.
198 199 200 |
# File 'lib/orientdb/sql/common.rb', line 198 def conditions @conditions end |
Instance Method Details
#<=>(other) ⇒ Object
242 243 244 |
# File 'lib/orientdb/sql/common.rb', line 242 def <=>(other) to_s <=> other.to_s end |
#add(*conds) ⇒ Object
209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/orientdb/sql/common.rb', line 209 def add(*conds) conds.each do |cond| case cond when ConditionExpression conditions << cond.to_s when Hash cond.each { |k, v| conditions << "#{k} = #{Query.quote(v)}" } when Array cond.each { |x| conditions << x.to_s } else conditions << cond.to_s end end end |
#clear ⇒ Object
224 225 226 |
# File 'lib/orientdb/sql/common.rb', line 224 def clear @conditions = [] end |
#conditions_str ⇒ Object
228 229 230 |
# File 'lib/orientdb/sql/common.rb', line 228 def conditions_str conditions.join(' AND ') end |
#parens_conditions_str ⇒ Object
232 233 234 |
# File 'lib/orientdb/sql/common.rb', line 232 def parens_conditions_str conditions.size > 1 ? "(#{conditions_str})" : conditions_str end |
#to_s ⇒ Object
236 237 238 |
# File 'lib/orientdb/sql/common.rb', line 236 def to_s "#{type} #{parens_conditions_str} " end |
#type ⇒ Object
205 206 207 |
# File 'lib/orientdb/sql/common.rb', line 205 def type @type.to_s.upcase.gsub('_', ' ') end |