ruby

elsif

SOFTWARE: ruby

if monkey banana elsif doggie bone end

ruby's version of else if:

ruby
if monkey
banana
elsif doggie
bone
end
MORE INFO:

add to an array in stages

SOFTWARE: ruby

my_array << 'item to add'

Set up an array first with:

ruby
my_array = Array.new

Then you can add to it in stages like so:

ruby
my_array << 'item_one'
my_array << 'item_two'

Cool beans. If you've got it nested in an each/do loop, you can automatically add stuff to your array from another array or whatever:

ruby
my_array = Array.new
my_old_array = ['item_one', 'item_two']
my_old_array.each do |value|
my_array << value
end

That would dump the values one at a time from my_old_array into my_array.

MORE INFO: http://www.thinkvitamin.com/features/ruby/ruby-arrays

some gem commands

SOFTWARE: ruby

gem install software_name

list locally installed gems:

gem list --local

search remote repo for gems whose name contains "ra"

gem search ra --remote

get a handy list of commands:

gem help commands

install a gem:

gem install software_name

update a gem:

gem update software_name
MORE INFO: http://rubygems.org/read/chapter/10
Comments