Class: BabelDiff::FileHandler

Inherits:
Struct
  • Object
show all
Defined in:
lib/babel_diff/file_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#current_version_pathObject

Returns the value of attribute current_version_path

Returns:

  • (Object)

    the current value of current_version_path



2
3
4
# File 'lib/babel_diff/file_handler.rb', line 2

def current_version_path
  @current_version_path
end

Instance Method Details

#create_additions(content) ⇒ Object



21
22
23
24
25
# File 'lib/babel_diff/file_handler.rb', line 21

def create_additions(content)
  File.open(additions_file_path, "w+") do |f|
    f.write(content)
  end
end

#create_updates(content) ⇒ Object



15
16
17
18
19
# File 'lib/babel_diff/file_handler.rb', line 15

def create_updates(content)
  File.open(updates_file_path, "w+") do |f|
    f.write(content)
  end
end

#current_versionObject



7
8
9
10
11
12
13
# File 'lib/babel_diff/file_handler.rb', line 7

def current_version
  if File.exist?(current_version_path)
    File.read(current_version_path)
  else
    raise "Phrase file not found"
  end
end

#previous_versionObject



3
4
5
# File 'lib/babel_diff/file_handler.rb', line 3

def previous_version
  File.exist?(previous_version_path) ? File.read(previous_version_path) : ""
end

#version_filesObject



27
28
29
30
31
32
# File 'lib/babel_diff/file_handler.rb', line 27

def version_files
  current_contents = File.read(current_version_path)
  File.open(previous_version_path, "w+") do |f|
    f.write(current_contents)
  end
end