Sha256: c9c3b4c2da8f72fc93823b918fd694ff881210fb91830213a6397e05c50beb45

Contents?: true

Size: 615 Bytes

Versions: 1

Compression:

Stored size: 615 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)
      elsif file?(name)
        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.4 lib/stashify/directory.rb