Class: Stashify::File::Local

Inherits:
Stashify::File show all
Defined in:
lib/stashify/file/local.rb

Overview

An implementation for interacting with local files. The constructor needs no information on top of what is included #initialize, although it’s important to note that setting the contents parameter will not do anything.

Instance Attribute Summary

Attributes inherited from Stashify::File

#name, #path

Instance Method Summary collapse

Methods inherited from Stashify::File

#==, #initialize

Constructor Details

This class inherits a constructor from Stashify::File

Instance Method Details

#contentsObject



12
13
14
# File 'lib/stashify/file/local.rb', line 12

def contents
  ::File.read(path)
end

#deleteObject



20
21
22
# File 'lib/stashify/file/local.rb', line 20

def delete
  ::File.delete(path)
end

#exists?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/stashify/file/local.rb', line 24

def exists?
  ::File.exist?(path)
end

#write(contents) ⇒ Object



16
17
18
# File 'lib/stashify/file/local.rb', line 16

def write(contents)
  ::File.write(path, contents)
end