Close

Ruby

Ruby – A hello world ruby script example

$ cat testscript.rb #!/usr/bin/env ruby a_string = “Hello World!” puts a_string puts a_string.class The first line is slightly unusual because: https://en.wikibooks.org/wiki/Ruby_Programming/Hello_world#Using_env Next make it an executable: $ chmod 777 testscript.rb then run the script: $ ./testscript.rb Hello World! String

Read More

RVM – Deleting a Ruby version

Any gems that you install while using an RVM’s ruby version, is self contained in that version. However there may come a time when you no longer want to use a particular ruby version and want to delete it along with all it’s gems. Then this can be done using […]

Read More

RVM – Using rvmsudo instead of sudo

There are times when you need to run a ruby related command to install something, e.g. “bundle install” or “gem install gem-name”. If you are an rvm managed ruby version, then it is bad/messy practice to do this. because doing so will install the gem system-wide, rather then ruby version […]

Read More

RVM – Installing a version of ruby

You are now ready to install a version of ruby to run on top of RMV. Before you install any new version of ruby to run on top of rvm, let’s first confirm that there are no versions of ruby running on top of rvm to begin with: [sher@puppetmaster ~]$ […]

Read More

Ruby – Environment Variable

You can read all the environment variables via the irb using the “ENV” command: irb(main):231:0* puts ENV.sort COLUMNS 188 HISTCONTROL ignoredups HISTSIZE 1000 HOME /root HOSTNAME puppetmaster.local LANG en_GB.UTF-8 . . …etc Here the keys are in capital and the values are in string. Alternatively we could use “pretty print” […]

Read More

Ruby – GemFile

Ruby gemfile the “:require => false” basically means that isn’t auto required. this means in your rb files, you have to have lots require statements to load in the gem’s utility before you can use it. You can also include if-else-conditions in your gem file. This gives you two ways […]

Read More