superject/cards/preprocess.rb

32 lines
849 B
Ruby

# convert text files into .csv for deck.rb mogrification
$cards_csv = "cards.csv"
$cards_o = "cards-occasions.txt"
$cards_q = "cards-qualifiers.txt"
$cards_v = "cards-verbs.txt"
# preamble...
File.open($cards_csv, "w")
File.write($cards_csv, "name,type,text,illustration\n", mode: "w")
# Occasions
def write_occasion(line)
File.write($cards_csv, "#{line},O,...,img/o_card.svg\n", mode: "a")
end
# Qualifiers
def write_qualifier(line)
File.write($cards_csv, "#{line},Q,...,img/q_card.svg\n", mode: "a")
end
# Verbs
def write_verb(line)
File.write($cards_csv, "#{line},V,...,img/v_card.svg\n", mode: "a")
end
# write to file...
File.foreach($cards_o) { |line| write_occasion line.chomp }
File.foreach($cards_q) { |line| write_qualifier line.chomp }
File.foreach($cards_v) { |line| write_verb line.chomp }