Class: Appwrite::Operator::Operator

Inherits:
Object
  • Object
show all
Defined in:
lib/appwrite/operator.rb

Class Method Summary collapse

Class Method Details

.array_append(values) ⇒ Object



93
94
95
# File 'lib/appwrite/operator.rb', line 93

def array_append(values)
    return Operator.new("arrayAppend", values).to_s
end

.array_diff(values) ⇒ Object



117
118
119
# File 'lib/appwrite/operator.rb', line 117

def array_diff(values)
    return Operator.new("arrayDiff", values).to_s
end

.array_filter(condition, value = nil) ⇒ Object



121
122
123
124
# File 'lib/appwrite/operator.rb', line 121

def array_filter(condition, value = nil)
    values = [condition, value]
    return Operator.new("arrayFilter", values).to_s
end

.array_insert(index, value) ⇒ Object



101
102
103
# File 'lib/appwrite/operator.rb', line 101

def array_insert(index, value)
    return Operator.new("arrayInsert", [index, value]).to_s
end

.array_intersect(values) ⇒ Object



113
114
115
# File 'lib/appwrite/operator.rb', line 113

def array_intersect(values)
    return Operator.new("arrayIntersect", values).to_s
end

.array_prepend(values) ⇒ Object



97
98
99
# File 'lib/appwrite/operator.rb', line 97

def array_prepend(values)
    return Operator.new("arrayPrepend", values).to_s
end

.array_remove(value) ⇒ Object



105
106
107
# File 'lib/appwrite/operator.rb', line 105

def array_remove(value)
    return Operator.new("arrayRemove", [value]).to_s
end

.array_unique ⇒ Object



109
110
111
# File 'lib/appwrite/operator.rb', line 109

def array_unique()
    return Operator.new("arrayUnique", []).to_s
end

.date_add_days(days) ⇒ Object



138
139
140
# File 'lib/appwrite/operator.rb', line 138

def date_add_days(days)
    return Operator.new("dateAddDays", [days]).to_s
end

.date_set_now ⇒ Object



146
147
148
# File 'lib/appwrite/operator.rb', line 146

def date_set_now()
    return Operator.new("dateSetNow", []).to_s
end

.date_sub_days(days) ⇒ Object



142
143
144
# File 'lib/appwrite/operator.rb', line 142

def date_sub_days(days)
    return Operator.new("dateSubDays", [days]).to_s
end

.decrement(value = 1, min = nil) ⇒ Object

Raises:

  • (ArgumentError)


49
50
51
52
53
54
55
56
# File 'lib/appwrite/operator.rb', line 49

def decrement(value = 1, min = nil)
    raise ArgumentError, "Value cannot be NaN or Infinity" if value.respond_to?(:nan?) && (value.nan? || value.infinite?)
    raise ArgumentError, "Min cannot be NaN or Infinity" if min != nil && min.respond_to?(:nan?) && (min.nan? || min.infinite?)

    values = [value]
    values << min if min != nil
    return Operator.new("decrement", values).to_s
end

.divide(divisor, min = nil) ⇒ Object

Raises:

  • (ArgumentError)


67
68
69
70
71
72
73
74
75
# File 'lib/appwrite/operator.rb', line 67

def divide(divisor, min = nil)
    raise ArgumentError, "Divisor cannot be NaN or Infinity" if divisor.respond_to?(:nan?) && (divisor.nan? || divisor.infinite?)
    raise ArgumentError, "Min cannot be NaN or Infinity" if min != nil && min.respond_to?(:nan?) && (min.nan? || min.infinite?)
    raise ArgumentError, "Divisor cannot be zero" if divisor == 0 || divisor == 0.0

    values = [divisor]
    values << min if min != nil
    return Operator.new("divide", values).to_s
end

.increment(value = 1, max = nil) ⇒ Object

Raises:

  • (ArgumentError)


40
41
42
43
44
45
46
47
# File 'lib/appwrite/operator.rb', line 40

def increment(value = 1, max = nil)
    raise ArgumentError, "Value cannot be NaN or Infinity" if value.respond_to?(:nan?) && (value.nan? || value.infinite?)
    raise ArgumentError, "Max cannot be NaN or Infinity" if max != nil && max.respond_to?(:nan?) && (max.nan? || max.infinite?)

    values = [value]
    values << max if max != nil
    return Operator.new("increment", values).to_s
end

.modulo(divisor) ⇒ Object

Raises:

  • (ArgumentError)


77
78
79
80
81
82
# File 'lib/appwrite/operator.rb', line 77

def modulo(divisor)
    raise ArgumentError, "Divisor cannot be NaN or Infinity" if divisor.respond_to?(:nan?) && (divisor.nan? || divisor.infinite?)
    raise ArgumentError, "Divisor cannot be zero" if divisor == 0 || divisor == 0.0

    return Operator.new("modulo", [divisor]).to_s
end

.multiply(factor, max = nil) ⇒ Object

Raises:

  • (ArgumentError)


58
59
60
61
62
63
64
65
# File 'lib/appwrite/operator.rb', line 58

def multiply(factor, max = nil)
    raise ArgumentError, "Factor cannot be NaN or Infinity" if factor.respond_to?(:nan?) && (factor.nan? || factor.infinite?)
    raise ArgumentError, "Max cannot be NaN or Infinity" if max != nil && max.respond_to?(:nan?) && (max.nan? || max.infinite?)

    values = [factor]
    values << max if max != nil
    return Operator.new("multiply", values).to_s
end

.power(exponent, max = nil) ⇒ Object

Raises:

  • (ArgumentError)


84
85
86
87
88
89
90
91
# File 'lib/appwrite/operator.rb', line 84

def power(exponent, max = nil)
    raise ArgumentError, "Exponent cannot be NaN or Infinity" if exponent.respond_to?(:nan?) && (exponent.nan? || exponent.infinite?)
    raise ArgumentError, "Max cannot be NaN or Infinity" if max != nil && max.respond_to?(:nan?) && (max.nan? || max.infinite?)

    values = [exponent]
    values << max if max != nil
    return Operator.new("power", values).to_s
end

.string_concat(value) ⇒ Object



126
127
128
# File 'lib/appwrite/operator.rb', line 126

def string_concat(value)
    return Operator.new("stringConcat", [value]).to_s
end

.string_replace(search, replace) ⇒ Object



130
131
132
# File 'lib/appwrite/operator.rb', line 130

def string_replace(search, replace)
    return Operator.new("stringReplace", [search, replace]).to_s
end

.toggle ⇒ Object



134
135
136
# File 'lib/appwrite/operator.rb', line 134

def toggle()
    return Operator.new("toggle", []).to_s
end