Class: Janeway::Interpreters::RootNodeDeleteIf
- Inherits:
-
RootNodeInterpreter
- Object
- Base
- RootNodeInterpreter
- Janeway::Interpreters::RootNodeDeleteIf
- Includes:
- IterationHelper
- Defined in:
- lib/janeway/interpreters/root_node_delete_if.rb
Overview
Delete values from the root node for which the block returns a truthy value.
Constant Summary
Constants included from IterationHelper
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(node, &block) ⇒ RootNodeDeleteIf
constructor
A new instance of RootNodeDeleteIf.
-
#interpret(_input, _parent, root, _path = nil) ⇒ Array
Delete values from the root container for which the block returns truthy.
Methods included from IterationHelper
#make_yield_proc, #normalized_path
Methods inherited from Base
#as_json, #selector, #to_s, #type
Constructor Details
#initialize(node, &block) ⇒ RootNodeDeleteIf
Returns a new instance of RootNodeDeleteIf.
13 14 15 16 17 18 19 |
# File 'lib/janeway/interpreters/root_node_delete_if.rb', line 13 def initialize(node, &block) super(node) @block = block # Make a proc that yields the correct number of values to a block @yield_proc = make_yield_proc(&block) end |
Instance Method Details
#interpret(_input, _parent, root, _path = nil) ⇒ Array
Delete values from the root container for which the block returns truthy.
28 29 30 31 32 33 34 |
# File 'lib/janeway/interpreters/root_node_delete_if.rb', line 28 def interpret(_input, _parent, root, _path = nil) case root when Array then maybe_delete_array_values(root) when Hash then maybe_delete_hash_values(root) else [] end end |