Class: Epubber::Services::Persistance

Inherits:
Object
  • Object
show all
Defined in:
lib/epubber/services/persistance.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(workspace) ⇒ Persistance

Returns a new instance of Persistance.



4
5
6
# File 'lib/epubber/services/persistance.rb', line 4

def initialize(workspace)
  @workspace = workspace
end

Instance Attribute Details

#workspaceObject (readonly)

Returns the value of attribute workspace.



3
4
5
# File 'lib/epubber/services/persistance.rb', line 3

def workspace
  @workspace
end

Instance Method Details

#cleanObject

Remove the working directory, thus cleaning the file system



16
17
18
# File 'lib/epubber/services/persistance.rb', line 16

def clean
  FileUtils.remove_dir workspace, true
end

#persist(file:, content:) ⇒ Object

Persist a file into the working directory with the spcified contents. The file argument is the relative path to the new file, eg: test/chapters/file.xhtml



10
11
12
13
# File 'lib/epubber/services/persistance.rb', line 10

def persist(file:, content:)
  create_path_for file
  write file, content
end