Class: Dynamicloud::API::Criteria::EqualCondition

Inherits:
Condition
  • Object
show all
Defined in:
lib/dynamic_criteria.rb

Overview

End of ANDCondition class

Constant Summary

Constants inherited from Condition

Condition::ROOT, Condition::WITHOUT

Instance Method Summary collapse

Constructor Details

#initialize(left, right, greater_lesser = '-') ⇒ EqualCondition

This constructor will build an equal condition using left and right parts.

Parameters:

  • left

    left part of this equal condition

  • right

    right part of this equal condition



108
109
110
111
112
113
# File 'lib/dynamic_criteria.rb', line 108

def initialize(left, right, greater_lesser = '-')
  @left = left
  @right = right
  @need_quotes = right.is_a? String
  @greater_lesser = greater_lesser
end

Instance Method Details

#to_record_string(parent) ⇒ Object

This method will return a String of this condition

Parameters:

  • parent

    this is the parent of this condition

Returns:

  • a json



118
119
120
121
122
123
124
125
# File 'lib/dynamic_criteria.rb', line 118

def to_record_string(parent)
  if @greater_lesser == '-'
    return '"' + @left.to_s + '" : ' + (@need_quotes ? '"' : '') + @right.to_s + (@need_quotes ? '"' : '');
  end

  '"' + @left.to_s + '" : { ' + (@greater_lesser == '>' ? '"$gte": ' : '"$lte": ') +
      (@need_quotes ? '"' : '') + @right.to_s + (@need_quotes ? '"' : '') + ' }'
end