Class: Literal::Hash

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/literal/hash.rb

Defined Under Namespace

Classes: Generic

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, key_type:, value_type:) ⇒ Hash



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/literal/hash.rb', line 25

def initialize(value, key_type:, value_type:)
  collection_type = Literal::Types::HashType.new(key_type, value_type)

  Literal.check(value, collection_type) do |c|
    c.fill_receiver(receiver: self, method: "#initialize")
  end

  @__key_type__ = key_type
  @__value_type__ = value_type
  @__value__ = value
  @__collection_type__ = collection_type
end

Instance Attribute Details

#__key_type__Object (readonly)

Returns the value of attribute key_type.



38
39
40
# File 'lib/literal/hash.rb', line 38

def __key_type__
  @__key_type__
end

#__value__Object (readonly)

Returns the value of attribute __value__.



38
39
40
# File 'lib/literal/hash.rb', line 38

def __value__
  @__value__
end

#__value_type__Object (readonly)

Returns the value of attribute value_type.



38
39
40
# File 'lib/literal/hash.rb', line 38

def __value_type__
  @__value_type__
end

Instance Method Details

#eachObject



45
46
47
# File 'lib/literal/hash.rb', line 45

def each(...)
  @__value__.each(...)
end

#freezeObject



40
41
42
43
# File 'lib/literal/hash.rb', line 40

def freeze
  @__value__.freeze
  super
end