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

#to_str, #type

Constructor Details

#initialize(type_list) ⇒ ListType

Returns a new instance of ListType.



54
55
56
57
58
# File 'lib/cel/ast/types.rb', line 54

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.



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

def element_type
  @element_type
end

Instance Method Details

#==(other) ⇒ Object



64
65
66
# File 'lib/cel/ast/types.rb', line 64

def ==(other)
  other == :list || super
end

#cast(value) ⇒ Object



68
69
70
# File 'lib/cel/ast/types.rb', line 68

def cast(value)
  List.new(value)
end

#get(idx) ⇒ Object



60
61
62
# File 'lib/cel/ast/types.rb', line 60

def get(idx)
  @type_list[idx]
end