Method: Janeway::Interpreters::IndexSelectorDeleter#interpret
- Defined in:
- lib/janeway/interpreters/index_selector_deleter.rb
#interpret(input, _parent, _root, _path) ⇒ Object
Interpret selector on the given input.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/janeway/interpreters/index_selector_deleter.rb', line 14 def interpret(input, _parent, _root, _path) return [] unless input.is_a?(Array) index = selector.value result = input.fetch(index) # raises IndexError if no such index input.delete_at(index) # returns nil if deleted value is nil, or if no value was deleted [result] rescue IndexError [] end |