Using a string as a class variable
Published on 26 Dec 2016
by Alexander Garber
My script relies on a single argument in the form $stdin user input:
The script is organised into a single class that contains consecutive methods.
The simplest way I have found to utilise the user input is to declare it in each method.
However, this is repetitive.
What would be a better way?
class Project
def initialize()
puts "What do you want to call this project?\n"
print "> "
$user_input = $stdin.gets.chomp
The script is organised into a single class that contains consecutive methods.
The simplest way I have found to utilise the user input is to declare it in each method.
def define_folders()
project_name = $user_input
def create_gemfile()
project_name = $user_input
However, this is repetitive.
What would be a better way?