Sha256: 2451aac0635c8edd1e6f42ebe1b1b880f1dad1ab17418e6a862bdfab622ac300
Contents?: true
Size: 969 Bytes
Versions: 5
Compression:
Stored size: 969 Bytes
Contents
module DirModel module Import class Path # Csv attr_reader :path attr_reader :index attr_reader :current_path def initialize(path) @path, @index = path, -1 reset! end def size @size ||= ruby_path.size end def reset! @index = -1 @current_path = @ruby_path = nil end def start? index == -1 end def end? index.nil? end def next_path ruby_path[index+1] end def previous_path return nil if index < 1 ruby_path[index-1] end def read_path return if end? @index += 1 @current_path = ruby_path[index] set_end unless current_path current_path end protected def ruby_path @ruby_path ||= ::Dir.glob("#{path}/**/*") end def set_end @current_path = @index = nil end end end end
Version data entries
5 entries across 5 versions & 1 rubygems