Class: TypedData::Schema::ArrayType

Inherits:
Type
  • Object
show all
Defined in:
lib/typed_data/schema/array_type.rb

Constant Summary

Constants inherited from Type

Type::SUPPORTED_LOGICAL_TYPES

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(types) ⇒ ArrayType

Returns a new instance of ArrayType.

Parameters:

  • types (Array<String>)


10
11
12
# File 'lib/typed_data/schema/array_type.rb', line 10

def initialize(types)
  @element_type = Schema.build_type(types)
end

Instance Attribute Details

#element_typeObject (readonly)

Returns the value of attribute element_type.



7
8
9
# File 'lib/typed_data/schema/array_type.rb', line 7

def element_type
  @element_type
end

Instance Method Details

#accept(visitor, value) ⇒ Object



14
15
16
# File 'lib/typed_data/schema/array_type.rb', line 14

def accept(visitor, value)
  visitor.visit_array(self, value)
end

#match?(value) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/typed_data/schema/array_type.rb', line 26

def match?(value)
  value.is_a?(Array) && value.all? { |v| @element_type.match?(v) }
end

#primitive?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/typed_data/schema/array_type.rb', line 22

def primitive?
  false
end

#to_sObject



18
19
20
# File 'lib/typed_data/schema/array_type.rb', line 18

def to_s
  "array_#{@element_type}"
end