Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/core_ext/array.rb
Instance Method Summary collapse
- #recursively_delete_keys!(*keys) ⇒ Object
- #recursively_remove_by_value!(&block) ⇒ Object
- #recursively_replace_keys!(&block) ⇒ Object
- #recursively_replace_values(&block) ⇒ Object
Instance Method Details
#recursively_delete_keys!(*keys) ⇒ Object
2 3 4 |
# File 'lib/core_ext/array.rb', line 2 def recursively_delete_keys! *keys self.each { |v| v.recursively_delete_keys!(*keys) if v.is_a?(Hash) || v.is_a?(Array) } ; self end |
#recursively_remove_by_value!(&block) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/core_ext/array.rb', line 18 def recursively_remove_by_value! &block self.delete_if { |v| if v.is_a? Hash v.recursively_remove_by_value! &block v.empty? elsif v.is_a? Array v.recursively_remove_by_value! &block v.empty? else yield v end } end |