Class: Epubber::Services::Persistance
- Inherits:
-
Object
- Object
- Epubber::Services::Persistance
- Defined in:
- lib/epubber/services/persistance.rb
Instance Attribute Summary collapse
-
#workspace ⇒ Object
readonly
Returns the value of attribute workspace.
Instance Method Summary collapse
-
#clean ⇒ Object
Remove the working directory, thus cleaning the file system.
-
#initialize(workspace) ⇒ Persistance
constructor
A new instance of Persistance.
-
#persist(file:, content:) ⇒ Object
Persist a file into the working directory with the spcified contents.
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
#workspace ⇒ Object (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
#clean ⇒ Object
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 |