Sha256: 2d2a6e3eb044c7c7cc6e280c3a26fd2d938a7692ff8e88634147b505c4081ffb

Contents?: true

Size: 602 Bytes

Versions: 1

Compression:

Stored size: 602 Bytes

Contents

# frozen_string_literal: true

module Stashify
  class Directory
    attr_reader :name, :files

    def initialize(name:, files: [])
      @name = name
      @files = files
    end

    def find(name)
      if directory?(name)
        directory(name)
      else
        file(name)
      end
    end

    def write(file)
      if file.is_a?(Stashify::Directory)
        write_directory(file)
      else
        write_file(file)
      end
    end

    def write_directory(directory)
      subdir = self.directory(directory.name)
      directory.files.each { |file| subdir.write(file) }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stashify-1.0.3 lib/stashify/directory.rb