Difference between revisions of "Ruby"

From Ever changing code
Jump to navigation Jump to search
Line 14: Line 14:
# require 'yaml'
# require 'yaml'
require 'fileutils'
require 'fileutils'
FileUtils.touch('file.txt.OK')
 
file_name="file.txt"
 
# #{file_name} -: string interpolation
FileUtils.touch("#{file_name}.OK")
</source>
</source>



Revision as of 11:06, 28 February 2019

Ruby adventures...

Install

sudo apt-get install ruby ruby-dev
 
# Install dependencies
bundler install

Basic file structure

#!/usr/bin/env ruby

# require 'yaml'
require 'fileutils'

file_name="file.txt"

# #{file_name} -: string interpolation
FileUtils.touch("#{file_name}.OK")

The require dependencies need to be installed using

sudo apt  install ruby-bundler
bundle install       #default, but NEVER RUN AS SUDO
bundle install -path #installs gems into ~/.path/