module Hash::Wrapper(K, V)
Overview
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}
Included Modules
- Enumerable({K, V})
- Iterable({K, V})
- Wrapper(Hash(K, V))
Direct including types
Defined in:
views/hash_wrapper.crConstructors
Instance Method Summary
- #[](*args, **options)
- #[](*args, **options, &)
- #[]?(*args, **options)
- #[]?(*args, **options, &)
- #compact(*args, **options)
- #compact(*args, **options, &)
- #dig(*args, **options)
- #dig(*args, **options, &)
- #dig?(*args, **options)
- #dig?(*args, **options, &)
- #each(*args, **options)
- #each(*args, **options, &)
- #each_key(*args, **options)
- #each_key(*args, **options, &)
- #each_value(*args, **options)
- #each_value(*args, **options, &)
- #empty?(*args, **options)
- #empty?(*args, **options, &)
- #fetch(*args, **options)
- #fetch(*args, **options, &)
- #first_key(*args, **options)
- #first_key(*args, **options, &)
- #first_key?(*args, **options)
- #first_key?(*args, **options, &)
- #first_value(*args, **options)
- #first_value(*args, **options, &)
- #first_value?(*args, **options)
- #first_value?(*args, **options, &)
- #has_key?(*args, **options)
- #has_key?(*args, **options, &)
- #has_value?(*args, **options)
- #has_value?(*args, **options, &)
- #inspect(io : IO) : Nil
- #invert(*args, **options)
- #invert(*args, **options, &)
- #key_for(*args, **options)
- #key_for(*args, **options, &)
- #key_for?(*args, **options)
- #key_for?(*args, **options, &)
- #keys(*args, **options)
- #keys(*args, **options, &)
- #last_key(*args, **options)
- #last_key(*args, **options, &)
- #last_key?(*args, **options)
- #last_key?(*args, **options, &)
- #last_value(*args, **options)
- #last_value(*args, **options, &)
- #last_value?(*args, **options)
- #last_value?(*args, **options, &)
- #merge(*args, **options)
- #merge(*args, **options, &)
- #proper_subset_of?(*args, **options)
- #proper_subset_of?(*args, **options, &)
- #proper_superset_of?(*args, **options)
- #proper_superset_of?(*args, **options, &)
- #reject(*args, **options)
- #reject(*args, **options, &)
- #select(*args, **options)
- #select(*args, **options, &)
- #size(*args, **options)
- #size(*args, **options, &)
- #subset_of?(*args, **options)
- #subset_of?(*args, **options, &)
- #superset_of?(*args, **options)
- #superset_of?(*args, **options, &)
- #to_a(*args, **options)
- #to_a(*args, **options, &)
-
#to_h : Hash(K, V)
Returns the wrapped hash.
- #to_s(*args, **options)
- #to_s(*args, **options, &)
- #transform_keys(*args, **options)
- #transform_keys(*args, **options, &)
- #transform_values(*args, **options)
- #transform_values(*args, **options, &)
- #values(*args, **options)
- #values(*args, **options, &)
- #values_at(*args, **options)
- #values_at(*args, **options, &)
Instance methods inherited from module Wrapper(Hash(K, V))
==(rhs : T(K, V)) : Bool==(rhs : self) : Bool ==, pretty_print(*args, **options)
pretty_print(*args, **options, &) pretty_print, to_s(*args, **options)
to_s(*args, **options, &) to_s, wrapped : T(K, V) wrapped