Module: MSFL::Validators::Definitions::HashKey

Included in:
Converters::Operator, Datasets::Base, Semantic
Defined in:
lib/msfl/validators/definitions/hash_key.rb

Instance Method Summary collapse

Instance Method Details

#all_logical_operators?(arr) ⇒ Bool

Returns true if all elements of arr are logical operators, false otherwise

Parameters:

  • arr (Array<Symbol>)

    and array of symbols to check to see if all elements are logical operators

Returns:

  • (Bool)

    it is true if all the elements are logical operators, otherwise false



56
57
58
59
60
61
# File 'lib/msfl/validators/definitions/hash_key.rb', line 56

def all_logical_operators?(arr)
  arr.each do |e|
    return false unless logical_operators.include?(e)
  end
  true
end

#all_operators?(arr) ⇒ Bool

Returns true if all elements of arr are operators, false otherwise

Parameters:

  • arr (Array<Symbol>)

    the Array of Symbols to be checked against the operators list

Returns:

  • (Bool)

    true if all of the elements of arr are operators



44
45
46
47
48
49
# File 'lib/msfl/validators/definitions/hash_key.rb', line 44

def all_operators?(arr)
  arr.each do |e|
    return false unless hash_key_operators.include?(e)
  end
  true
end

#any_operators?(arr) ⇒ Bool

Returns true if any of the elements in arr are operators, otherwise false

Parameters:

  • arr (Array)

    the array of elements to check for the presence of operators

Returns:

  • (Bool)

    true if any of the elements of arr are operators



67
68
69
70
71
72
# File 'lib/msfl/validators/definitions/hash_key.rb', line 67

def any_operators?(arr)
  arr.each do |e|
    return true if hash_key_operators.include?(e)
  end
  false
end

#binary_operatorsObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/msfl/validators/definitions/hash_key.rb', line 19

def binary_operators
  [
      :in,          # IN
      :between,     # inclusive range for integers, dates, and date times
      :start,       # a range bound inclusively to the left
      :end,         # a range bound inclusively to the right
      :ellipsis2,   # alias to :between
      :tilda,       # alias to :between, :start, and :end depending on usage
      :eq,          # ==
      :lt,          # <
      :lte,         # <=
      :gt,          # >
      :gte,         # >=
      :neg,         # logical negation
  ]
end

#hash_key_operatorsObject

Operators still needing parsing: ellipsis2, tilda



15
16
17
# File 'lib/msfl/validators/definitions/hash_key.rb', line 15

def hash_key_operators
  binary_operators.concat(logical_operators)
end

#logical_operatorsObject



36
37
38
# File 'lib/msfl/validators/definitions/hash_key.rb', line 36

def logical_operators
  [:and, :or]
end

#valid_hash_key?(key) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/msfl/validators/definitions/hash_key.rb', line 6

def valid_hash_key?(key)
  valid_hash_keys.include? key
end

#valid_hash_keysObject



10
11
12
# File 'lib/msfl/validators/definitions/hash_key.rb', line 10

def valid_hash_keys
  hash_key_operators.concat self.dataset.fields
end