Class: OData::Query::Criteria

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Criteria

Initializes a new criteria with provided options.

Parameters:

  • options (Hash) (defaults to: {})


15
16
17
18
19
# File 'lib/odata/query/criteria.rb', line 15

def initialize(options = {})
  @property = options[:property]
  @operator = options[:operator]
  @value    = options[:value]
end

Instance Attribute Details

#operatorObject (readonly)

The operator of the criteria.



9
10
11
# File 'lib/odata/query/criteria.rb', line 9

def operator
  @operator
end

#propertyObject (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

#valueObject (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.

Parameters:

Returns:

  • (self)


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.

Parameters:

Returns:

  • (self)


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.

Parameters:

Returns:

  • (self)


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.

Parameters:

Returns:

  • (self)


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.

Parameters:

Returns:

  • (self)


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.

Parameters:

Returns:

  • (self)


31
32
33
# File 'lib/odata/query/criteria.rb', line 31

def ne(value)
  set_operator_and_value(:ne, value)
end

#to_sObject

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