Professional Documents
Culture Documents
RubyCheat PDF
RubyCheat PDF
Ruby arguments
$!
Exception information
-c
Check
$@
Array of backtrace
-d
Debug
$&
-e
One Line
$`
-h
Help
-n
gets loop
Types
Expressions
Variables
$+
-rL
require L
12345
if expr [then]
elsif expr
[then]
else
end
local
$N
-v
verbose
@instance
$~
-w
warnings
@@class
$=
-y
comp debug
CONSTANT
$/
$\
Reserved Words
$,
alias
$.
and
$>
Default output
BEGIN
$_
begin
$*
break
$0
Name of script
case
$$
Process number
class
def
$stderr
defined?
$stdin
Standard input
do
$stdout
Standard output
else
123.45
1.23e-4
0xFF00
1...5
unless expr
[then]
else
end
Operators and
Precedence
a..z
expr if expr
::
a...z
expr unless
expr
[]
0b01100
1..5
string sq
string dq
#{expr}
\t\r\n
%q(string sq)
%Q(string dq)
%(string dq)
<<id string id
:symbol
/regex/opt
%r|regex|
[1, 2, 3]
%w(1 2 3)
%W(1 2 #{expr})
{1=>2, :s=>v}
case expr
when comp
else
end
+ - ! ~
&
Exceptions
begin
rescue ex =>
var
else
ensure
end
StandardError
ZeroDivisionError
RangeError
SecurityError
IOError
IndexError
RuntimeError
**
Module/Class
module Name
end
class Name
end
class Name <
Sup
end
class << obj
end
def
name(args...)
end
def inst.
name(...)
end
public
protected
private
attr_reader
attr_writer
attr
attr_accessor
* / %
<< >>
| ^
> >= < <=
<=> == === !=
=~
elsif
&&
Regex
.. ...
all characters
end
= ( += -= )
[ ]
ensure
not
[^ ]
false
and or
zero or more
for
one or more
if
zero or one
in
alteration
module
( )
Group
next
nil
not
{1,5}
1 to 5
or
\A
Beginning of a string
redo
\b
Word boundary
rescue
\B
Non-word boundary
retry
\d
return
\D
Non-digit
self
\s
Whitespace
super
\S
Non-whitespace
then
\w
Word-character
true
\W
Non-word-character
undef
\z
End of a string
unless
\Z
until
Constants
__FILE__
__LINE__
ENV
ARGF
ARGV
END
when
while
yield
Object
Array
File
Array#clear
String
r+
w+
Hash
a+
Hash#clear
Dir
Dir::chdir ([string])
Dir::delete (string)
Test::Unit
Dir#close
Dir#rewind
block_given?
DateTime
DateTime::now
DateTime::parse (str)
DateTime::strptime (str, format)
DateTime#day
DateTime#hour
DateTime#leap?
DateTime#min
DateTime#month
DateTime#sec
DateTime#wday
DateTime#year
assert_respond_to(obj, method
[,msg])
assert_same (expected, actual
[,msg])
Ruby: www.ruby-lang.org
Doc: www.ruby-doc.org