Module: Cel

Includes:
CollectionTypeFetch
Defined in:
lib/cel.rb,
lib/cel/macro.rb,
lib/cel/errors.rb,
lib/cel/parser.rb,
lib/cel/checker.rb,
lib/cel/context.rb,
lib/cel/encoder.rb,
lib/cel/program.rb,
lib/cel/version.rb,
lib/cel/ast/types.rb,
lib/cel/parser.tab.rb,
lib/cel/environment.rb,
lib/cel/ast/elements.rb,
lib/cel/ast/elements/protobuf.rb

Defined Under Namespace

Modules: CollectionTypeFetch, Encoder, Macro, Protobuf, Ruby Classes: BindingError, Bool, Bytes, CheckError, Checker, Condition, Context, Duration, Environment, Error, EvaluateError, Function, Group, Identifier, Invoke, List, ListType, Literal, Map, MapType, Message, NoMatchingOverloadError, NoSuchFieldError, Null, Number, Operation, ParseError, Parser, Program, Runner, String, Timestamp, Type

Constant Summary collapse

PRIMITIVE_TYPES =

Primitive Cel Types

%i[int uint double bool string bytes list map timestamp duration null_type type].freeze
COLTYPES =
%i[list map].freeze
TYPES =
(PRIMITIVE_TYPES - COLTYPES).to_h { |typ| [typ, Type.new(typ)] }
LOGICAL_OPERATORS =
%w[<= >= < > == != in].freeze
MULTI_OPERATORS =
%w[* / %].freeze

Class Method Summary collapse

Methods included from CollectionTypeFetch

#[]

Class Method Details

.to_numeric(anything) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/cel.rb', line 16

def self.to_numeric(anything)
  num = BigDecimal(anything.to_s)
  if num.frac.zero?
    num.to_i
  else
    num.to_f
  end
end