class GeneratePairs
Constants
- FILE_EXTENSION
Attributes
source[R]
Public Class Methods
load_names(file_path)
click to toggle source
# File lib/makers_toolbelt/generate_pairs.rb, line 9 def self.load_names(file_path) File.readlines(file_path).map(&:strip) end
new(options = {})
click to toggle source
# File lib/makers_toolbelt/generate_pairs.rb, line 13 def initialize(options = {}) @source = options[:source] end
Public Instance Methods
path()
click to toggle source
# File lib/makers_toolbelt/generate_pairs.rb, line 25 def path File.join(source_directory, filename) end
run()
click to toggle source
# File lib/makers_toolbelt/generate_pairs.rb, line 17 def run names = GeneratePairs.load_names(source) File.open(path, 'w') do |file| puts "Pair assignments created in file #{path}" file.write names.one_factorize.shuffle.to_json end end
Private Instance Methods
filename()
click to toggle source
# File lib/makers_toolbelt/generate_pairs.rb, line 35 def filename "#{File.basename(source)}.#{FILE_EXTENSION}" end
source_directory()
click to toggle source
# File lib/makers_toolbelt/generate_pairs.rb, line 31 def source_directory File.dirname(source) end