Showing posts with label Ruby. Show all posts
Showing posts with label Ruby. Show all posts

Tuesday, September 10, 2013

Ruby Predefined Variables

This is a list of the frequently used predefined variables in ruby:

Exceptions
$! message of the last exception
$@ backtrace of the last exception

Regexp
$& the string that matched the last last regexp match
$` string preceding $&
$’ string following $&
$+ last parentheses match
$1, $2, $3… parentheses matches
$~ MatchData object containing information about the last match
$= case insensitive flag

Separators
$/ used by gets, readline etc. as a separator (defaults to “\n”)
$\ used by print, write etc. as a separator (defaults to nil)
$, used by Array#join
$; used by String#split

IO
$< program input
$> program output
$stdin standard input
$stdout standard output
$stderr standard error output
$. line number of the last read file
$_ last input line - used by gets, readline

Process
$0 program name
$* command line arguments
$$ PID of the program
$? exit status of the last process
$: $LOAD_PATH
$” all filenames required by the script
$SAFE security level 0-4, 0 having no restrictions and being the default
$DEBUG debugger enabled?

Friday, September 6, 2013

TryRuby

Learn ruby basic commands in 15 minutes using the link http://tryruby.org, Which has command line interpreter, and you can have short desc for each command. You can go back and forth to check.

Wednesday, August 28, 2013

ERROR: Error installing rails: activesupport requires Ruby version >= 1.9.3.

Check whether you are trying to install the correct version of Rails that are compatible with your Ruby Version.

You can check the ruby version by running the cmd "ruby -v"

Rails VersionPossible Ruby VersionsRecommended Ruby Version
1.0–2.11.8.61.8.6
2.21.8.6 or 1.8.71.8.7
2.31.8.6, 1.8.7, or 1.9.11.8.7
3.0–3.21.8.7, 1.9.2, or 1.9.31.9.3
4.0–…1.9.3, 2.0.x2.0.x

then try to install the rails

sudo gem install rails --version 3.2.12