Class: Cel::Literal
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Cel::Literal
- Defined in:
- lib/cel/ast/elements.rb
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(type, value) ⇒ Literal
constructor
A new instance of Literal.
Constructor Details
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
136 137 138 |
# File 'lib/cel/ast/elements.rb', line 136 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
136 137 138 |
# File 'lib/cel/ast/elements.rb', line 136 def value @value end |
Class Method Details
.to_cel_type(val) ⇒ Object
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/cel/ast/elements.rb', line 149 def self.to_cel_type(val) val = Protobuf.convert_from_protobuf(val) if val.is_a?(Google::Protobuf::MessageExts) case val when Literal, Identifier val # TODO: should support byte streams? when ::String String.new(val) when ::Symbol Identifier.new(val) when ::Integer Number.new(:int, val) when ::Float, ::BigDecimal Number.new(:double, val) when ::Hash Map.new(val) when ::Array List.new(val) when true, false Bool.new(val) when nil Null.new when Time Timestamp.new(val) else raise BindingError, "can't convert #{val} to CEL type" end end |
Instance Method Details
#==(other) ⇒ Object
145 146 147 |
# File 'lib/cel/ast/elements.rb', line 145 def ==(other) @value == other || super end |