From 667edb63697aa9aff55e54a3ed2fde8425e14956 Mon Sep 17 00:00:00 2001 From: s00ner Date: Tue, 12 Jul 2022 17:06:42 -0400 Subject: [PATCH] fixed formatting --- aocinit.rb | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/aocinit.rb b/aocinit.rb index 1906eb8..f450179 100644 --- a/aocinit.rb +++ b/aocinit.rb @@ -2,29 +2,29 @@ require 'optparse' require 'HTTParty' -options = Hash.new +options = {} OptionParser.new do |opts| - opts.banner = 'aocinit.rb --help' - opts.on("-y", "--year year", "AoC year") do |year| - options[:year] = year - end - opts.on("-d", "--day day", "AoC day") do |day| - options[:day] = day - end - opts.on("-c", "--cookie-file cookie", "File containing your AoC cookie") do |cookie| - options[:cookie] = cookie - end + opts.banner = 'aocinit.rb --help' + opts.on('-y', '--year year', 'AoC year') do |year| + options[:year] = year + end + opts.on('-d', '--day day', 'AoC day') do |day| + options[:day] = day + end + opts.on('-c', '--cookie-file cookie', 'File containing your AoC cookie') do |cookie| + options[:cookie] = cookie + end end.parse! url = "https://adventofcode.com/#{options[:year]}/day/#{options[:day]}/input" -options[:day] = "0" + options[:day] if options[:day].to_i < 10 +options[:day] = '0' + options[:day] if options[:day].to_i < 10 newdir = "./day#{options[:day]}" cookie = File.read("./#{options[:cookie]}") -@options = { headers: { 'Cookie' => "session=#{cookie}" }} +@options = { headers: { 'Cookie' => "session=#{cookie}" } } input = HTTParty.get(url, @options) -abort "Day already initiated." if Dir.exists?(newdir) +abort 'Day already initiated.' if Dir.exist?(newdir) Dir.mkdir(newdir) Dir.chdir(newdir) File.write('./input', input) -File.write('./solution.rb', "#!/bin/env ruby") \ No newline at end of file +File.write('./solution.rb', '#!/bin/env ruby')