class Gemirro::MirrorFile
Similar to {Gemirro::MirrorDirectory} the MirrorFile
class is used to make it easier to read and write data in a directory that mirrors data from an external source.
@!attribute [r] path
@return [String]
Attributes
Public Class Methods
Source
# File lib/gemirro/mirror_file.rb, line 18 def initialize(path) @path = path end
@param [String] path
Public Instance Methods
Source
# File lib/gemirro/mirror_file.rb, line 41 def read handle = File.open(@path, 'r') content = handle.read handle.close content end
Reads the content of the current file.
@return [String]
Source
# File lib/gemirro/mirror_file.rb, line 28 def write(content) FileUtils.mkdir_p(File.dirname(@path)) handle = File.open(@path, 'w') handle.write(content) handle.close end
Writes the specified content to the current file. Existing files are overwritten.
@param [String] content