class Gemirro::MirrorDirectory
The MirrorDirectory
is used for dealing with files and directories that are mirrored from an external source.
@!attribute [r] path
@return [String]
Attributes
path[R]
Public Class Methods
new(path)
click to toggle source
@param [String] path
# File lib/gemirro/mirror_directory.rb, line 17 def initialize(path) @path = path end
Public Instance Methods
add_directory(dir_path)
click to toggle source
Creates directory or directories with the given path.
@param [String] dir_path @return [Gemirro::MirrorDirectory]
# File lib/gemirro/mirror_directory.rb, line 27 def add_directory(dir_path) full_path = File.join(@path, dir_path) FileUtils.mkdir_p(full_path) unless File.directory?(full_path) self.class.new(full_path) end
add_file(name, content)
click to toggle source
Creates a new file with the given name and content.
@param [String] name @param [String] content @return [Gem::MirrorFile]
# File lib/gemirro/mirror_directory.rb, line 41 def add_file(name, content) full_path = File.join(@path, name) file = MirrorFile.new(full_path) file.write(content) file end
file_exists?(name)
click to toggle source
Checks if a given file exists in the current directory.
@param [String] name @return [TrueClass|FalseClass]
# File lib/gemirro/mirror_directory.rb, line 56 def file_exists?(name) File.file?(File.join(@path, name)) end