Class: GeneratePairs
- Inherits:
-
Object
- Object
- GeneratePairs
- Defined in:
- lib/makers_toolbelt/generate_pairs.rb
Constant Summary collapse
- FILE_EXTENSION =
'pairs'
Instance Attribute Summary collapse
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ GeneratePairs
constructor
A new instance of GeneratePairs.
- #path ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ GeneratePairs
Returns a new instance of GeneratePairs.
13 14 15 |
# File 'lib/makers_toolbelt/generate_pairs.rb', line 13 def initialize( = {}) @source = [:source] end |
Instance Attribute Details
#source ⇒ Object (readonly)
Returns the value of attribute source.
7 8 9 |
# File 'lib/makers_toolbelt/generate_pairs.rb', line 7 def source @source end |
Class Method Details
.load_names(file_path) ⇒ Object
9 10 11 |
# File 'lib/makers_toolbelt/generate_pairs.rb', line 9 def self.load_names(file_path) File.readlines(file_path).map(&:strip) end |
Instance Method Details
#path ⇒ Object
25 26 27 |
# File 'lib/makers_toolbelt/generate_pairs.rb', line 25 def path File.join(source_directory, filename) end |
#run ⇒ Object
17 18 19 20 21 22 23 |
# 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 |