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.
- #to_ruby_type ⇒ Object
Constructor Details
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
147 148 149 |
# File 'lib/cel/ast/elements.rb', line 147 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
147 148 149 |
# File 'lib/cel/ast/elements.rb', line 147 def value @value end |
Class Method Details
.to_cel_type(val) ⇒ Object
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/cel/ast/elements.rb', line 161 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
156 157 158 159 |
# File 'lib/cel/ast/elements.rb', line 156 def ==(other) other = other.value if other.is_a?(Literal) @value == other || super end |
#to_ruby_type ⇒ Object
191 192 193 |
# File 'lib/cel/ast/elements.rb', line 191 def to_ruby_type @value end |