module DataFiles
require 'init'
Public Class Methods
prepare()
click to toggle source
# File lib/shunkuntype/db.rb, line 8 def self.prepare data_path = File.join(ENV['HOME'], '.shunkuntype','training_data.txt') create_file_if_not_exists(data_path) end
Private Class Methods
create_data_files()
click to toggle source
# File lib/shunkuntype/db.rb, line 25 def self.create_data_files if File::exist?("./speed_data.txt") then system "mv ./speed_data.txt #{Shunkuntype::SPEED_FILE}" print "moving ./speed_data.txt #{Shunkuntype::SPEED_FILE}.\n" end if File::exist?("./training_data.txt") then system "mv ./training_data.txt #{Shunkuntype::TRAIN_FILE}" print "moving ./training_data.txt #{Shunkuntype::TRAIN_FILE}.\n" end if File::exist?(Shunkuntype::SPEED_FILE) then print "#{Shunkuntype::SPEED_FILE} exits.\n" else File::open(Shunkuntype::SPEED_FILE,'a') print "make #{Shunkuntype::SPEED_FILE}\n" end if File::exist?(Shunkuntype::TRAIN_FILE) then print "#{Shunkuntype::TRAIN_FILE} exits.\n" else File::open(Shunkuntype::TRAIN_FILE,'a') print "make #{Shunkuntype::TRAIN_FILE}\n" end end
create_file_if_not_exists(path)
click to toggle source
# File lib/shunkuntype/db.rb, line 14 def self.create_file_if_not_exists(path) create_file_path(path) return if File::exists?(path) create_data_files end
create_file_path(path)
click to toggle source
# File lib/shunkuntype/db.rb, line 21 def self.create_file_path(path) FileUtils.mkdir_p File.dirname(path) end