Class: Cel::MapType
Instance Attribute Summary collapse
-
#element_type ⇒ Object
Returns the value of attribute element_type.
Instance Method Summary collapse
- #get(attrib) ⇒ Object
-
#initialize(type_map) ⇒ MapType
constructor
A new instance of MapType.
Methods inherited from Type
Constructor Details
#initialize(type_map) ⇒ MapType
Returns a new instance of MapType.
66 67 68 69 70 |
# File 'lib/cel/ast/types.rb', line 66 def initialize(type_map) super(:map) @type_map = type_map @element_type = @type_map.empty? ? TYPES[:any] : @type_map.keys.sample.type end |
Instance Attribute Details
#element_type ⇒ Object
Returns the value of attribute element_type.
64 65 66 |
# File 'lib/cel/ast/types.rb', line 64 def element_type @element_type end |
Instance Method Details
#get(attrib) ⇒ Object
72 73 74 75 |
# File 'lib/cel/ast/types.rb', line 72 def get(attrib) _, value = @type_map.find { |k, _| k == attrib.to_s } value end |