Sha256: 230ea6634e6d138eecd136543178e62f1e0977439bd1737b75e1e31355065c9d

Contents?: true

Size: 514 Bytes

Versions: 1

Compression:

Stored size: 514 Bytes

Contents

module TodoNext

  class Tree
    class ParentsList

      def initialize(parents=nil)
        @parents = parents || { -1 => nil }
      end

      def register_parent(new_parent, options)
        curr_col = options.fetch(:for_col)
        @parents[1+curr_col] = new_parent
        @parents.delete_if{|k, v| k > 1+curr_col }
      end

      def get_for_item_at_column(curr_col)
        parent_key = @parents.keys.sort.reverse.detect {|col| col < curr_col}
        @parents[parent_key]
      end
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
todo_next-0.0.1 lib/todo_next/tree/parents_list.rb