Module: Qrb::CollectionType

Included in:
SeqType, SetType
Defined in:
lib/qrb/support/collection_type.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#elm_typeObject (readonly)

Returns the value of attribute elm_type.



12
13
14
# File 'lib/qrb/support/collection_type.rb', line 12

def elm_type
  @elm_type
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



14
15
16
17
# File 'lib/qrb/support/collection_type.rb', line 14

def ==(other)
  return false unless other.is_a?(self.class)
  elm_type == other.elm_type
end

#hashObject



20
21
22
# File 'lib/qrb/support/collection_type.rb', line 20

def hash
  self.class.hash ^ self.elm_type.hash
end

#initialize(elm_type, name = nil) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/qrb/support/collection_type.rb', line 4

def initialize(elm_type, name = nil)
  unless elm_type.is_a?(Type)
    raise ArgumentError, "Qrb::Type expected, got `#{elm_type}`"
  end

  super(name)
  @elm_type = elm_type
end