Class: TreeFilter::NullSlice

Inherits:
Object
  • Object
show all
Defined in:
lib/tree_filter.rb

Overview

Indicates no more filtering for the given object, return it as is.

Instance Method Summary collapse

Instance Method Details

#filter(x) ⇒ Object


76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/tree_filter.rb', line 76

def filter(x)
  case x
  when Hash
    x.each_with_object({}) do |(k, v), h|
      h[k] = filter(v)
    end
  when Array
    x.map {|y| filter(y) }
  when Defer
    filter(x.call)
  when Leaf
    filter(x.left)
  else
    x
  end
end