Class: Lockness::Edit

Inherits:
Object
  • Object
show all
Defined in:
lib/lockness/edit.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEdit

Returns a new instance of Edit.



8
9
10
11
12
# File 'lib/lockness/edit.rb', line 8

def initialize
  @encrypted_file = EncryptedFile.new(path: PathBuilder.path)
  @content     = Content.new(encrypted_file: encrypted_file)
  @temp_file   = Tempfile.new
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



4
5
6
# File 'lib/lockness/edit.rb', line 4

def content
  @content
end

#encrypted_fileObject (readonly)

Returns the value of attribute encrypted_file.



4
5
6
# File 'lib/lockness/edit.rb', line 4

def encrypted_file
  @encrypted_file
end

#temp_fileObject (readonly)

Returns the value of attribute temp_file.



4
5
6
# File 'lib/lockness/edit.rb', line 4

def temp_file
  @temp_file
end

Instance Method Details

#editObject



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/lockness/edit.rb', line 14

def edit
  ensure_temp_file_deleted

  if encrypted_file.exist?
    edit_existing
  else
    edit_new
  end

  puts "File saved: #{encrypted_file.encrypted_path}"
end