Class: FrOData::Query::Criteria

Inherits:
Object
  • Object
show all
Includes:
ComparisonOperators, DateFunctions, GeographyFunctions, LambdaOperators, StringFunctions
Defined in:
lib/frodata/query/criteria.rb,
lib/frodata/query/criteria/date_functions.rb,
lib/frodata/query/criteria/lambda_operators.rb,
lib/frodata/query/criteria/string_functions.rb,
lib/frodata/query/criteria/geography_functions.rb,
lib/frodata/query/criteria/comparison_operators.rb

Overview

Represents a discreet criteria within an FrOData::Query. Should not, normally, be instantiated directly.

Defined Under Namespace

Modules: ComparisonOperators, DateFunctions, GeographyFunctions, LambdaOperators, StringFunctions

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from LambdaOperators

#all, #any

Methods included from GeographyFunctions

#distance, #intersects

Methods included from DateFunctions

#date, #day, #fractionalseconds, #hour, #minute, #month, #second, #time, #year

Methods included from StringFunctions

#contains, #endswith, #startswith, #tolower, #toupper

Methods included from ComparisonOperators

#eq, #ge, #gt, #le, #lt, #ne

Constructor Details

#initialize(options = {}) ⇒ Criteria

Initializes a new criteria with provided options.

Parameters:

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


25
26
27
28
29
30
31
# File 'lib/frodata/query/criteria.rb', line 25

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

Instance Attribute Details

#argumentObject (readonly)

An optional argument to the function.



21
22
23
# File 'lib/frodata/query/criteria.rb', line 21

def argument
  @argument
end

#functionObject (readonly)

A function to apply to the property.



19
20
21
# File 'lib/frodata/query/criteria.rb', line 19

def function
  @function
end

#operatorObject (readonly)

The operator of the criteria.



15
16
17
# File 'lib/frodata/query/criteria.rb', line 15

def operator
  @operator
end

#propertyObject (readonly)

The property name that is the target of the criteria.



13
14
15
# File 'lib/frodata/query/criteria.rb', line 13

def property
  @property
end

#valueObject (readonly)

The value of the criteria.



17
18
19
# File 'lib/frodata/query/criteria.rb', line 17

def value
  @value
end

Instance Method Details

#to_sObject

Returns criteria as query-ready string.



40
41
42
43
44
45
46
47
48
# File 'lib/frodata/query/criteria.rb', line 40

def to_s
  query = function ? function_expression : property_name

  if operator && !lambda_operator?
    "#{query} #{operator} #{url_value(value)}"
  else
    query
  end
end