Ruby beginner Having issue writing variables to user created .txt file

this is some thing I’m doing for my job, I figured I’d try it in ruby

instead of doing it in c++ with qt…

class Setup
attr_accessor :folder, :file

class MakeListings
attr_accessor :website, :username, :password, :description

def Install()

@folder = gets.chomp
Dir.mkdir(@folder) unless Dir.exists?(@folder)
@file = gets.chomp,“w+”)

def CreateWebsite()

wMessage_one = “\nPlease input the site for this listing”

puts wMessage_one

@website = gets.chomp, “a+”)

file << “#{@website}”




#I would have indented but it kept cutting it off and making it look

Every thing works except for opening and writing to the file

the File path contains the absolute file path given by the user.

Example c:\Random Test

So the folder gets created

#and then c:\Random Test\Hello there.txt the text file is created

How can I open this text file and append it? It doesn’t seem to like

the #@file variable

Aside from the fact that the usage of the idea of sharing the @file
variable between two top-level functions, while technically correct, is
a bit odd, note that you are using inside your function CreateWebsite
two DIFFERENT variables with similar name: ‘@file’, which is an instance
variable (in this case, I think, injected into the instance of type
Object, because you are not within a class definition), and ‘file’,
which is a local variable within the function.

BTW, be a little bit more precise when describing a problem. When you
say “It doesn’t seem to like …”, this is not something which has a
deeper meaning. Does it crash? Does it throw an exception? Does it hang