Class: TypeStruct::ArrayOf

Inherits:
Object
  • Object
show all
Includes:
Unionable
Defined in:
lib/type_struct/array_of.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Unionable

#|

Constructor Details

#initialize(type) ⇒ ArrayOf

Returns a new instance of ArrayOf.



7
8
9
# File 'lib/type_struct/array_of.rb', line 7

def initialize(type)
  @type = type
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



6
7
8
# File 'lib/type_struct/array_of.rb', line 6

def type
  @type
end

Instance Method Details

#===(other) ⇒ Object



16
17
18
19
# File 'lib/type_struct/array_of.rb', line 16

def ===(other)
  return false unless Array === other
  other.all? { |o| @type === o }
end

#to_sObject Also known as: inspect



11
12
13
# File 'lib/type_struct/array_of.rb', line 11

def to_s
  "#{self.class}(#{@type})"
end