Sha256: 185cfd99a7da7eb73cb6a2ca4e1b445eb7285511f449bcc3b7ca35b4c454b481
Contents?: true
Size: 993 Bytes
Versions: 2
Compression:
Stored size: 993 Bytes
Contents
# frozen_string_literal: true module Stashify class Directory attr_reader :name, :files, :path def initialize(name: nil, path: nil, files: []) raise StandardError, "name or path must be defined" unless name || path @path = path @name = name || ::File.basename(path) @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 def ==(other) files == other.files end def eql?(other) self.class == other.class && name == other.name && path == other.path end private def path_of(name) ::File.join(path, name) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
stashify-2.0.0 | lib/stashify/directory.rb |
stashify-1.0.5 | lib/stashify/directory.rb |