class SaveMe

Constants

VERSION

Attributes

filepath[R]
new_filepath[R]
params[R]

Public Class Methods

call(filepath, results_path: "./", ymd: 0b111, params: nil) click to toggle source
# File lib/save_me.rb, line 8
def self.call(filepath, results_path: "./", ymd: 0b111, params: nil)
  new(filepath, results_path, ymd, params).call
end
new(filepath, results_path, ymd, params) click to toggle source
# File lib/save_me.rb, line 12
def initialize(filepath, results_path, ymd, params)
  @filepath = filepath
  @new_filepath = PathGenerator.call(filepath, results_path, ymd)
  @params = params
end

Public Instance Methods

call() click to toggle source
# File lib/save_me.rb, line 18
def call
  create_dir
  copy_file
  save_params
end

Private Instance Methods

copy_file() click to toggle source
# File lib/save_me.rb, line 30
def copy_file
  FileUtils.cp_r(filepath, new_filepath)
end
create_dir() click to toggle source
# File lib/save_me.rb, line 26
def create_dir
  FileUtils.mkdir_p(new_filepath)
end
save_params() click to toggle source
# File lib/save_me.rb, line 34
def save_params
  return nil unless params
  params_path = "#{new_filepath}/params.json"
  File.open(params_path, "w") do |file|
    file << params.to_json
  end
end