Using a string as a class variable
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?
Published on 26 Dec 2016
by Alexander Garber
all tags
100daysofcode activerecord android annoyances api apt arch array artix atom az3w backend bash blog browser bug callback career ci-cd cli cloud code coding config configuration cp crud cryptography css csv database db design devops django docker email erp feelsgood filter fugitive gif gist git gnome gnome pomodoro grep hebrew http ide isbn-fetcher iso javascript job search js kanban kindle koans learning linkedin linux logger manjaro map markdown microservices mobi mtp neovim nodejs nvchad packages panda pastbin patch portfolio post postgres pytest python rails reduce refactoring reflections rest routes rspec ruby salesforce script scripting security sed shell sql string_replacement study tdd terminal testing tmux ttd version_control vim vim sort walkthrough webdev workflow zsh