Sha256: 4e247af21fac1b3c82fd54669ca1ed87ee50920fac7723ba79685706c29e011c

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.2 lib/todo_next/tree/parents_list.rb