Class: TypeStruct::HashOf
- Includes:
- Unionable
- Defined in:
- lib/type_struct/ext.rb,
lib/type_struct/hash_of.rb
Instance Attribute Summary collapse
-
#key_type ⇒ Object
readonly
Returns the value of attribute key_type.
-
#value_type ⇒ Object
readonly
Returns the value of attribute value_type.
Instance Method Summary collapse
- #===(other) ⇒ Object
-
#initialize(key_type, value_type) ⇒ HashOf
constructor
A new instance of HashOf.
- #to_s ⇒ Object (also: #inspect)
Methods included from Unionable
Constructor Details
#initialize(key_type, value_type) ⇒ HashOf
Returns a new instance of HashOf.
8 9 10 11 |
# File 'lib/type_struct/hash_of.rb', line 8 def initialize(key_type, value_type) @key_type = key_type @value_type = value_type end |
Instance Attribute Details
#key_type ⇒ Object (readonly)
Returns the value of attribute key_type.
7 8 9 |
# File 'lib/type_struct/hash_of.rb', line 7 def key_type @key_type end |
#value_type ⇒ Object (readonly)
Returns the value of attribute value_type.
7 8 9 |
# File 'lib/type_struct/hash_of.rb', line 7 def value_type @value_type end |
Instance Method Details
#===(other) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/type_struct/hash_of.rb', line 13 def ===(other) return false unless Hash === other other.all? do |k, v| @key_type === k && @value_type === v end end |
#to_s ⇒ Object Also known as: inspect
19 20 21 |
# File 'lib/type_struct/ext.rb', line 19 def to_s "#{self.class.name.split('::').last}(#{@key_type}, #{@value_type})" end |