Class: TypeStruct::ArrayOf

Inherits:
Object
  • Object
show all
Defined in:
lib/type_struct/arrayof.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ ArrayOf

Returns a new instance of ArrayOf.



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

def initialize(type)
  @type = type
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



5
6
7
# File 'lib/type_struct/arrayof.rb', line 5

def type
  @type
end

Instance Method Details

#===(other) ⇒ Object



19
20
21
22
# File 'lib/type_struct/arrayof.rb', line 19

def ===(other)
  return false unless other.respond_to?(:any?)
  other.any? { |o| @type === o }
end

#to_sObject Also known as: inspect



14
15
16
# File 'lib/type_struct/arrayof.rb', line 14

def to_s
  "#<#{self.class} #{@type}>"
end

#|(other) ⇒ Object



10
11
12
# File 'lib/type_struct/arrayof.rb', line 10

def |(other)
  Union.new(self, other)
end