def key_parts(key, &block)
      return enum_for(:key_parts, key) unless block
      nesting = PARENS
      counts  = PARENS_ZEROS # dup'd later if key contains parenthesis
      delim   = '.'
      from    = to = 0
      key.each_char do |char|
        if char == delim && PARENS_ZEROS == counts
          block.yield key[from...to]
          from = to = (to + 1)
        else
          nest_i, nest_inc = nesting[char]
          if nest_i
            counts = counts.dup if counts.frozen?
            counts[nest_i] += nest_inc
          end
          to += 1
        end
      end
      block.yield(key[from...to]) if from < to && to <= key.length
      true
    end
def key_parts(key, &block)
      return enum_for(:key_parts, key) unless block
      nesting = PARENS
      counts  = PARENS_ZEROS # dup'd later if key contains parenthesis
      delim   = '.'
      from    = to = 0
      key.each_char do |char|
        if char == delim && PARENS_ZEROS == counts
          block.yield key[from...to]
          from = to = (to + 1)
        else
          nest_i, nest_inc = nesting[char]
          if nest_i
            counts = counts.dup if counts.frozen?
            counts[nest_i] += nest_inc
          end
          to += 1
        end
      end
      block.yield(key[from...to]) if from < to && to <= key.length
      true
    end
def key_parts ( key , & block ) return enum_for ( :key_parts , key ) unless block nesting = PARENS counts = PARENS_ZEROS # dup'd later if key contains parenthesis delim = '.' from = to = 0 key . each_char do | char | if char == delim && PARENS_ZEROS == counts block . yield key [ from ... to ] from = to = ( to + 1 ) else nest_i , nest_inc = nesting [ char ] if nest_i counts = counts . dup if counts . frozen? counts [ nest_i ] += nest_inc end to += 1 end end block . yield ( key [ from ... to ] ) if from < to && to <= key . length true end
yield each key part
 dots inside braces or parenthesis are not split on
yield each key part dots inside braces or parenthesis are not split on