Class: Jinx::Hashable::KeyFilter

Inherits:
Filter show all
Includes:
Jinx::Hashable
Defined in:
lib/jinx/helpers/hashable.rb

Overview

See Also:

Instance Method Summary collapse

Methods included from Jinx::Hashable

#==, #assoc_values, #compact, #compose, #copy_recursive, #detect_key, #detect_key_with_value, #diff, #each_key, #each_pair, #each_value, #enum_keys, #enum_keys_with_value, #enum_values, #filter, #filter_on_key, #filter_on_value, #flatten, #has_key?, #has_value?, #inspect, #join, #keys, #pretty_print, #pretty_print_cycle, #qp, #reject_keys, #reject_values, #select_keys, #select_values, #sort, #split, #to_hash, #to_s, #to_set, #transform_key, #transform_value, #union, #values

Methods included from Enumerable

#collection?, #compact, #compact_map, #detect_value, #detect_with_value, #difference, #empty?, #enumerate, #filter, #first, #flatten, #hashify, #intersect, #join, #last, #partial_sort, #partial_sort_by, #pp_s, #pretty_print, #pretty_print_cycle, #qp, #size, #to_compact_hash, #to_compact_hash_with_index, #to_enum, #to_series, #transform, #transitive_closure, #union

Methods inherited from Filter

#each

Constructor Details

#initialize(base) ⇒ KeyFilter

Returns a new instance of KeyFilter.



364
365
366
# File 'lib/jinx/helpers/hashable.rb', line 364

def initialize(base)
  super(base) { |k, v| yield(k) }
end

Instance Method Details

#[](key) ⇒ Object



368
369
370
# File 'lib/jinx/helpers/hashable.rb', line 368

def [](key)
  super if @filter.call(key, nil)
end