Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Apr 042013

Constant in Ruby


In Ruby, a class constant has a name starting with an uppercase character, e.g.

Foo = 'bar'
puts Foo

Where you try to re-define the constant, a warning message will be shown, e.g.

Foo = 'bar'
Foo = '123'

(irb):18: warning: already initialized constant Foo
Mar 292013

Global and Local variable in Ruby


In Ruby, global variable has a name beginning with $, e.g.

$foo = 'bar'
puts $foo

In contrast, local variable has a name start with a lower case letter or an underscore character, e.g.

foo = 'bar'
puts foo
Jul 012011

List of remote gems on


To list all the available gems on, use this command:

# gem list --remote

For example, to search for all rails related gems, use

# gem list --remote | grep "\-rails"

Jun 272011

List all the installed gems


To list all the installed gems on your machine, simply execute the following command:

# gem list --local

*** LOCAL GEMS ***

abstract (1.0.0)
actionmailer (3.0.9)
actionpack (3.0.9)
activemodel (3.0.9)
activerecord (3.0.9)
activeresource (3.0.9)
activesupport (3.0.9)
arel (2.0.10)
builder (2.1.2)
erubis (2.6.6)
i18n (0.5.0)
mail (2.2.19)
mime-types (1.16)
polyglot (0.3.1)
rack (1.2.3)
rack-mount (0.6.14)
rack-test (0.5.7)
rake (0.9.2)
treetop (1.4.9)
tzinfo (0.3.28)