module

Hash::Wrapper(K, V)

Inherits Wrapper < Iterable < Enumerable

Wraps a Hash object. The including type will behave as a read-only hash, where objects returned by methods will be wrapped as well if the return type is the same as the original hash.

class Table
  include HashWrapper(String, Int32)
end

table = Table.new({"a" => 1, "b" => 2})
table["a"]?                   # => 1
table["b"]?                   # => 2
table["c"]?                   # => nil
table["c"] = 3                # does not compile
table.select { |_, v| v > 2 } # => Table{"b" => 2}

Constructors

new(wrapped : Hash(K, V) = {} of K => V)
Source

Instance methods

[](*args, **options)
Source
[](*args, **options, &)
Source
[]?(*args, **options)
Source
[]?(*args, **options, &)
Source
compact(*args, **options)
Source
compact(*args, **options, &)
Source
dig(*args, **options)
Source
dig(*args, **options, &)
Source
dig?(*args, **options)
Source
dig?(*args, **options, &)
Source
each(*args, **options)
Source
each(*args, **options, &)
Source
each_key(*args, **options)
Source
each_key(*args, **options, &)
Source
each_value(*args, **options)
Source
each_value(*args, **options, &)
Source
empty?(*args, **options)
Source
empty?(*args, **options, &)
Source
fetch(*args, **options)
Source
fetch(*args, **options, &)
Source
first_key(*args, **options)
Source
first_key(*args, **options, &)
Source
first_key?(*args, **options)
Source
first_key?(*args, **options, &)
Source
first_value(*args, **options)
Source
first_value(*args, **options, &)
Source
first_value?(*args, **options)
Source
first_value?(*args, **options, &)
Source
has_key?(*args, **options)
Source
has_key?(*args, **options, &)
Source
has_value?(*args, **options)
Source
has_value?(*args, **options, &)
Source
inspect(io : IO) : Nil
Source
invert(*args, **options)
Source
invert(*args, **options, &)
Source
key_for(*args, **options)
Source
key_for(*args, **options, &)
Source
key_for?(*args, **options)
Source
key_for?(*args, **options, &)
Source
keys(*args, **options)
Source
keys(*args, **options, &)
Source
last_key(*args, **options)
Source
last_key(*args, **options, &)
Source
last_key?(*args, **options)
Source
last_key?(*args, **options, &)
Source
last_value(*args, **options)
Source
last_value(*args, **options, &)
Source
last_value?(*args, **options)
Source
last_value?(*args, **options, &)
Source
merge(*args, **options)
Source
merge(*args, **options, &)
Source
proper_subset_of?(*args, **options)
Source
proper_subset_of?(*args, **options, &)
Source
proper_superset_of?(*args, **options)
Source
proper_superset_of?(*args, **options, &)
Source
reject(*args, **options)
Source
reject(*args, **options, &)
Source
select(*args, **options)
Source
select(*args, **options, &)
Source
size(*args, **options)
Source
size(*args, **options, &)
Source
subset_of?(*args, **options)
Source
subset_of?(*args, **options, &)
Source
superset_of?(*args, **options)
Source
superset_of?(*args, **options, &)
Source
to_a(*args, **options)
Source
to_a(*args, **options, &)
Source
to_h

Returns the wrapped hash.

Source
to_s(*args, **options)
Source
to_s(*args, **options, &)
Source
transform_keys(*args, **options)
Source
transform_keys(*args, **options, &)
Source
transform_values(*args, **options)
Source
transform_values(*args, **options, &)
Source
values(*args, **options)
Source
values(*args, **options, &)
Source
values_at(*args, **options)
Source
values_at(*args, **options, &)
Source