Sha256: b0bcd5ea9978cc4b74c6b20b59155cc17802034e51c857c865f963490661dc46
Contents?: true
Size: 497 Bytes
Versions: 1
Compression:
Stored size: 497 Bytes
Contents
module Depth class Traverser < Struct.new(:object) def array? object.is_a?(Array) end def hash? object.is_a?(Hash) end def next(key_or_index) return Traverser.new(nil) if object.nil? Traverser.new(object[key_or_index]) end def next_or_create(key_or_index, &block) return Traverser.new(nil) if object.nil? object[key_or_index] = block.call if object[key_or_index].nil? Traverser.new(object[key_or_index]) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
depth-0.3.0 | lib/depth/traverser.rb |