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?
all tags
activerecord android annoyances api apt arch array artix atom az3w backend bash blog browser bug callback career cli cloud code coding config configuration cp crud css database db design devops django email erp filter fugitive gif gist git gnome grep hebrew http ide isbn-fetcher iso javascript job search js kanban kanban\ kindle koans linux logger manjaro map markdown microservices mobi mtp neovim nodejs packages pastbin patch post python rails reduce refactoring rest routes rspec ruby scripting security sed shell sql string_replacement study tdd terminal testing version_control vim walkthrough workflow