22 lines
500 B
Ruby
22 lines
500 B
Ruby
require 'json'
|
|
|
|
#txt = open("actions.txt")
|
|
#print txt.read
|
|
txt = open("input.txt")
|
|
#puts txt.read
|
|
filenames = ["actions.txt", "directions.txt", "movement.txt"]
|
|
dictionary = {}
|
|
#filenames.each do |name|
|
|
#f = File.read(name).include?
|
|
#end
|
|
txt.each_line do |line|
|
|
filenames.each do |name|
|
|
if File.read(name).include?line
|
|
dictionary[name.chomp('.txt')] = line.chomp("\n")
|
|
end
|
|
end
|
|
end
|
|
|
|
puts dictionary
|
|
File.open("test.json", "w") {|f| f.write(dictionary.to_json)}
|