Class: OData::Query::Criteria
- Inherits:
-
Object
- Object
- OData::Query::Criteria
- Defined in:
- lib/odata/query/criteria.rb
Overview
Represents a discreet criteria within an OData::Query. Should not, normally, be instantiated directly.
Instance Attribute Summary collapse
-
#operator ⇒ Object
readonly
The operator of the criteria.
-
#property ⇒ Object
readonly
The property name that is the target of the criteria.
-
#value ⇒ Object
readonly
The value of the criteria.
Instance Method Summary collapse
-
#eq(value) ⇒ self
Sets up equality operator.
-
#ge(value) ⇒ self
Sets up greater-than-or-equal operator.
-
#gt(value) ⇒ self
Sets up greater-than operator.
-
#initialize(options = {}) ⇒ Criteria
constructor
Initializes a new criteria with provided options.
-
#le(value) ⇒ self
Sets up less-than-or-equal operator.
-
#lt(value) ⇒ self
Sets up less-than operator.
-
#ne(value) ⇒ self
Sets up non-equality operator.
-
#to_s ⇒ Object
Returns criteria as query-ready string.
Constructor Details
#initialize(options = {}) ⇒ Criteria
Initializes a new criteria with provided options.
15 16 17 18 19 |
# File 'lib/odata/query/criteria.rb', line 15 def initialize( = {}) @property = [:property] @operator = [:operator] @value = [:value] end |
Instance Attribute Details
#operator ⇒ Object (readonly)
The operator of the criteria.
9 10 11 |
# File 'lib/odata/query/criteria.rb', line 9 def operator @operator end |
#property ⇒ Object (readonly)
The property name that is the target of the criteria.
7 8 9 |
# File 'lib/odata/query/criteria.rb', line 7 def property @property end |
#value ⇒ Object (readonly)
The value of the criteria.
11 12 13 |
# File 'lib/odata/query/criteria.rb', line 11 def value @value end |
Instance Method Details
#eq(value) ⇒ self
Sets up equality operator.
24 25 26 |
# File 'lib/odata/query/criteria.rb', line 24 def eq(value) set_operator_and_value(:eq, value) end |
#ge(value) ⇒ self
Sets up greater-than-or-equal operator.
45 46 47 |
# File 'lib/odata/query/criteria.rb', line 45 def ge(value) set_operator_and_value(:ge, value) end |
#gt(value) ⇒ self
Sets up greater-than operator.
38 39 40 |
# File 'lib/odata/query/criteria.rb', line 38 def gt(value) set_operator_and_value(:gt, value) end |
#le(value) ⇒ self
Sets up less-than-or-equal operator.
59 60 61 |
# File 'lib/odata/query/criteria.rb', line 59 def le(value) set_operator_and_value(:le, value) end |
#lt(value) ⇒ self
Sets up less-than operator.
52 53 54 |
# File 'lib/odata/query/criteria.rb', line 52 def lt(value) set_operator_and_value(:lt, value) end |
#ne(value) ⇒ self
Sets up non-equality operator.
31 32 33 |
# File 'lib/odata/query/criteria.rb', line 31 def ne(value) set_operator_and_value(:ne, value) end |
#to_s ⇒ Object
Returns criteria as query-ready string.
64 65 66 |
# File 'lib/odata/query/criteria.rb', line 64 def to_s "#{property.name} #{operator} #{url_value}" end |