Class: Cel::ListType

Inherits:
Type
  • Object
show all
Defined in:
lib/cel/ast/types.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Type

#==, #cast, #to_str, #type

Constructor Details

#initialize(type_list) ⇒ ListType

Returns a new instance of ListType.



52
53
54
55
56
# File 'lib/cel/ast/types.rb', line 52

def initialize(type_list)
  super(:list)
  @type_list = type_list
  @element_type = @type_list.empty? ? TYPES[:any] : @type_list.sample.type
end

Instance Attribute Details

#element_typeObject

Returns the value of attribute element_type.



50
51
52
# File 'lib/cel/ast/types.rb', line 50

def element_type
  @element_type
end

Instance Method Details

#get(idx) ⇒ Object



58
59
60
# File 'lib/cel/ast/types.rb', line 58

def get(idx)
  @type_list[idx]
end