pry-docmore 0.0.4 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/docmores.yaml +618 -0
- data/lib/pry-docmore.rb +7 -6
- metadata +4 -98
- data/pry-docmore.wiki/Home.md +0 -96
- data/pry-docmore.wiki/Ruby Global $! (DollarBang).md +0 -15
- data/pry-docmore.wiki/Ruby Global $/" (DollarQuote).md" +0 -4
- data/pry-docmore.wiki/Ruby Global $$ (DollarDollar).md +0 -12
- data/pry-docmore.wiki/Ruby Global $& (DollarAmpersand).md +0 -16
- data/pry-docmore.wiki/Ruby Global $' (DollarTick).md +0 -16
- data/pry-docmore.wiki/Ruby Global $* (DollarStar).md +0 -1
- data/pry-docmore.wiki/Ruby Global $+ (DollarPlus).md +0 -9
- data/pry-docmore.wiki/Ruby Global $, (DollarComma).md +0 -1
- data/pry-docmore.wiki/Ruby Global $-0 (DollarDashZero).md +0 -1
- data/pry-docmore.wiki/Ruby Global $-F (DollarDashF).md +0 -1
- data/pry-docmore.wiki/Ruby Global $-I (DollarDashI).md +0 -1
- data/pry-docmore.wiki/Ruby Global $-K (DollarDashK).md +0 -1
- data/pry-docmore.wiki/Ruby Global $-W (DollarDashW).md +0 -1
- data/pry-docmore.wiki/Ruby Global $-a (DollarDasha).md +0 -1
- data/pry-docmore.wiki/Ruby Global $-d (DollarDashd).md +0 -1
- data/pry-docmore.wiki/Ruby Global $-i (DollarDashi).md +0 -1
- data/pry-docmore.wiki/Ruby Global $-l (DollarDashl).md +0 -1
- data/pry-docmore.wiki/Ruby Global $-p (DollarDashp).md +0 -1
- data/pry-docmore.wiki/Ruby Global $-v (DollarDashv).md +0 -1
- data/pry-docmore.wiki/Ruby Global $-w (DollarDashw).md +0 -1
- data/pry-docmore.wiki/Ruby Global $. (DollarDot).md +0 -1
- data/pry-docmore.wiki/Ruby Global $0 (DollarZero).md +0 -2
- data/pry-docmore.wiki/Ruby Global $1 (DollarOne).md +0 -1
- data/pry-docmore.wiki/Ruby Global $2 (DollarTwo).md +0 -1
- data/pry-docmore.wiki/Ruby Global $3 (DollarThree).md +0 -1
- data/pry-docmore.wiki/Ruby Global $4 (DollarFour).md +0 -1
- data/pry-docmore.wiki/Ruby Global $5 (DollarFive).md +0 -1
- data/pry-docmore.wiki/Ruby Global $6 (DollarSix).md +0 -1
- data/pry-docmore.wiki/Ruby Global $7 (DollarSeven).md +0 -1
- data/pry-docmore.wiki/Ruby Global $8 (DollarEight).md +0 -1
- data/pry-docmore.wiki/Ruby Global $9 (DollarNine).md +0 -1
- data/pry-docmore.wiki/Ruby Global $: (DollarColon).md +0 -3
- data/pry-docmore.wiki/Ruby Global $; (DollarSemicolon).md +0 -1
- data/pry-docmore.wiki/Ruby Global $< (DollarLessthan).md +0 -1
- data/pry-docmore.wiki/Ruby Global $= (DollarEquals).md +0 -2
- data/pry-docmore.wiki/Ruby Global $> (DollarGreaterthan).md +0 -1
- data/pry-docmore.wiki/Ruby Global $? (Dollar?).md +0 -11
- data/pry-docmore.wiki/Ruby Global $@ (DollarAt).md +0 -2
- data/pry-docmore.wiki/Ruby Global $DEBUG (DollarDEBUG).md +0 -1
- data/pry-docmore.wiki/Ruby Global $FILENAME (DollarFILENAME).md +0 -1
- data/pry-docmore.wiki/Ruby Global $KCODE (DollarKCODE).md +0 -1
- data/pry-docmore.wiki/Ruby Global $LOADED_FEATURES (DollarLOADEDUnderscoreFEATURES).md +0 -1
- data/pry-docmore.wiki/Ruby Global $LOAD_PATH (DollarLOADUnderscorePATH).md +0 -1
- data/pry-docmore.wiki/Ruby Global $PROGRAM_NAME (DollarPROGRAMUnderscoreNAME).md +0 -1
- data/pry-docmore.wiki/Ruby Global $SAFE (DollarSAFE).md +0 -4
- data/pry-docmore.wiki/Ruby Global $VERBOSE (DollarVERBOSE).md +0 -1
- data/pry-docmore.wiki/Ruby Global $// (DollarBackslash).md" +0 -1
- data/pry-docmore.wiki/Ruby Global $_ (DollarUnderscore).md +0 -1
- data/pry-docmore.wiki/Ruby Global $` (DollarBacktick).md +0 -16
- data/pry-docmore.wiki/Ruby Global $stderr (Dollarstderr).md +0 -1
- data/pry-docmore.wiki/Ruby Global $stdin (Dollarstdin).md +0 -1
- data/pry-docmore.wiki/Ruby Global $stdout (Dollarstdout).md +0 -1
- data/pry-docmore.wiki/Ruby Global $~ (DollarSquiggle).md +0 -1
- data/pry-docmore.wiki/Ruby Global $/342/201/204 (DollarSlash).md" +0 -3
- data/pry-docmore.wiki/Ruby Keyword: BEGIN.md +0 -14
- data/pry-docmore.wiki/Ruby Keyword: END.md +0 -10
- data/pry-docmore.wiki/Ruby Keyword: __ENCODING__.md +0 -8
- data/pry-docmore.wiki/Ruby Keyword: __FILE__.md +0 -5
- data/pry-docmore.wiki/Ruby Keyword: __LINE__.md +0 -12
- data/pry-docmore.wiki/Ruby Keyword: alias.md +0 -38
- data/pry-docmore.wiki/Ruby Keyword: and.md +0 -29
- data/pry-docmore.wiki/Ruby Keyword: begin.md +0 -24
- data/pry-docmore.wiki/Ruby Keyword: break.md +0 -22
- data/pry-docmore.wiki/Ruby Keyword: case.md +0 -25
- data/pry-docmore.wiki/Ruby Keyword: class.md +0 -4
- data/pry-docmore.wiki/Ruby Keyword: def.md +0 -14
- data/pry-docmore.wiki/Ruby Keyword: defined?.md +0 -29
- data/pry-docmore.wiki/Ruby Keyword: do.md +0 -3
- data/pry-docmore.wiki/Ruby Keyword: else.md +0 -4
- data/pry-docmore.wiki/Ruby Keyword: elsif.md +0 -3
- data/pry-docmore.wiki/Ruby Keyword: end.md +0 -2
- data/pry-docmore.wiki/Ruby Keyword: ensure.md +0 -1
- data/pry-docmore.wiki/Ruby Keyword: false.md +0 -9
- data/pry-docmore.wiki/Ruby Keyword: for.md +0 -14
- data/pry-docmore.wiki/Ruby Keyword: if.md +0 -5
- data/pry-docmore.wiki/Ruby Keyword: in.md +0 -3
- data/pry-docmore.wiki/Ruby Keyword: module.md +0 -31
- data/pry-docmore.wiki/Ruby Keyword: next.md +0 -15
- data/pry-docmore.wiki/Ruby Keyword: nil.md +0 -3
- data/pry-docmore.wiki/Ruby Keyword: not.md +0 -10
- data/pry-docmore.wiki/Ruby Keyword: or.md +0 -22
- data/pry-docmore.wiki/Ruby Keyword: redo.md +0 -16
- data/pry-docmore.wiki/Ruby Keyword: rescue.md +0 -55
- data/pry-docmore.wiki/Ruby Keyword: retry.md +0 -20
- data/pry-docmore.wiki/Ruby Keyword: return.md +0 -38
- data/pry-docmore.wiki/Ruby Keyword: self.md +0 -15
- data/pry-docmore.wiki/Ruby Keyword: super.md +0 -34
- data/pry-docmore.wiki/Ruby Keyword: then.md +0 -17
- data/pry-docmore.wiki/Ruby Keyword: true.md +0 -7
- data/pry-docmore.wiki/Ruby Keyword: undef.md +0 -5
- data/pry-docmore.wiki/Ruby Keyword: unless.md +0 -4
- data/pry-docmore.wiki/Ruby Keyword: until.md +0 -6
- data/pry-docmore.wiki/Ruby Keyword: when.md +0 -1
- data/pry-docmore.wiki/Ruby Keyword: while.md +0 -6
- data/pry-docmore.wiki/Ruby Keyword: yield.md +0 -16
data/docmores.yaml
ADDED
|
@@ -0,0 +1,618 @@
|
|
|
1
|
+
---
|
|
2
|
+
Ruby Global $stdout (Dollarstdout): ! 'The $stdout global is the current standard
|
|
3
|
+
output.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
This is file descriptor 1, traditionally.
|
|
7
|
+
|
|
8
|
+
'
|
|
9
|
+
Ruby Global $< (DollarLessthan): ! 'The $< global is the virtual concatenation file
|
|
10
|
+
of the files given on command line (or from $stdin if no files were given).
|
|
11
|
+
|
|
12
|
+
'
|
|
13
|
+
! 'Ruby Keyword: case': ! "A convenient conditional that doesn't require the \"subject\"
|
|
14
|
+
to be repeated.\n\nUses #=== for comparison (\"the threequals\"), which is defined
|
|
15
|
+
specially for\nvarious objects.\n\n x = 'asdf'\n case x\n when 'asdf';
|
|
16
|
+
puts 'Found it!'\n when 'fghj'; puts 'Impossible.'\n else puts 'Also impossible.'\n
|
|
17
|
+
\ end\n\n case x\n when String; puts 'Yep, will get here.'\n when Array;
|
|
18
|
+
puts 'Actually, wait a minute.'\n when Hash; puts 'This is pretty bad OO.'\n
|
|
19
|
+
\ else puts 'But, the code works'\n end\n\n case x\n when /^[fdsa]{4}/;
|
|
20
|
+
puts 'Whoa, works with regexes.'\n else puts 'Will not get here.'\n end\n\nAlso
|
|
21
|
+
works with `Range`s"
|
|
22
|
+
! 'Ruby Keyword: next': ! "Skip to the next iteration of the inner-most loop.\n\nFor
|
|
23
|
+
example:\n\n 10.times do |i|\n next unless 0 == i % 3\n print i\n end\n
|
|
24
|
+
\ puts\n\nPrints:\n\n 0369\n\nCompare with: break, last\n"
|
|
25
|
+
! 'Ruby Keyword: begin': ! "Opens a block when `def` or `do` isn't already opening
|
|
26
|
+
one for you.\n\nUses include:\n\n begin\n 1/0\n rescue => e\n p
|
|
27
|
+
e\n else\n puts 'Cannot get here with that 1/0'\n ensure\n puts
|
|
28
|
+
'OK then.'\n end\n\nOr something like:\n\n x = something_falsy || begin\n
|
|
29
|
+
\ several_steps\n go_here\n 3\n end\n # Now x == 3\n\n(Not to
|
|
30
|
+
be confused with the BEGIN keyword.)\n"
|
|
31
|
+
Ruby Global $, (DollarComma): ! 'The $, global is the output field separator for the
|
|
32
|
+
print and Array#join.
|
|
33
|
+
|
|
34
|
+
'
|
|
35
|
+
! 'Ruby Keyword: or': ! "Boolean disjunction.\n\n Evaluates to true if either its
|
|
36
|
+
left or right side are true.\n\n Remember that the 'or' operator is lower precedence
|
|
37
|
+
operator than '||', so\n\n an_expression or another_expression\n is roughly
|
|
38
|
+
equivalent to:\n (an_expression) || (another_expression)\n\nTruth table\n\n true
|
|
39
|
+
\ or true ⇒ true\n false or true ⇒ true\n false or false ⇒ false\n\nPrecedence\n\n
|
|
40
|
+
\ true or false ? 'yes' : 'no' ⇒ true\n true || false ? 'yes' : 'no' ⇒ \"yes\"\n\nSee
|
|
41
|
+
http://phrogz.net/ProgrammingRuby/language.html#table_18.4\n"
|
|
42
|
+
Ruby Global $@ (DollarAt): ! "The $@ global holds the Array of backtrace in the format:\n\n
|
|
43
|
+
\ \"file:line:in `method`\"\n\nwhile in a `rescue` block.\n"
|
|
44
|
+
Ruby Global $-p (DollarDashp): ! 'The $-p global is true if option -p is set. Read-only
|
|
45
|
+
variable.
|
|
46
|
+
|
|
47
|
+
'
|
|
48
|
+
! 'Ruby Keyword: do': ! 'The beginning of a block, to be passed to a method call.
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
TODO - https://github.com/rking/pry-docmore/wiki
|
|
52
|
+
|
|
53
|
+
'
|
|
54
|
+
! 'Ruby Keyword: __LINE__': ! "The code's current line number. Can be a handy way
|
|
55
|
+
to pepper what would\notherwise be `print \"Got here 1\"` statements in your code,
|
|
56
|
+
e.g.:\n\n if a\n p __LINE__\n # some stuff\n else\n p
|
|
57
|
+
__LINE__\n # some other stuff\n end\n\n…but you use the pry-debugger gem
|
|
58
|
+
instead, don't you?\n"
|
|
59
|
+
! 'Ruby Keyword: module': ! "Usage: module ModuleName; module-contents end\n\nDefines
|
|
60
|
+
a new Module, or re-opens an existing module. Modules in ruby are\ncollections of
|
|
61
|
+
code, they have two distinct use-cases:\n\n1. As a Namespace. Often all of the code
|
|
62
|
+
in a rubygem will be written in the\nsame module to avoid naming collisions with
|
|
63
|
+
code not in that Gem.\n\n2. As a set of shared functions. Modules can be included
|
|
64
|
+
into Classes, which\nmakes all of the methods defined in the module available to
|
|
65
|
+
instances of the\nclass. This can be used to emulate multiple-inheritance, or to
|
|
66
|
+
divide one large\nclass into more manageable chunks.\n\nNote that, though the class
|
|
67
|
+
`Class` inherits from `Module`, this is more of an\nimplementation detail than a
|
|
68
|
+
direct, Liskov-substitutable interface: modules\ncan be `include`d, `extend`ed or
|
|
69
|
+
`using`d, while classes cannot. (On the other\nhand, classes can be instantiated,
|
|
70
|
+
where modules cannot).\n\n module X\n def foo; 2 end\n end\n class
|
|
71
|
+
Y; include X end\n class Z; extend X end\n # Now, these work:\n Y.new.foo\n
|
|
72
|
+
\ Z.foo\n # \"extend just calls include on the eigenclass\"\n # Mnemonic!
|
|
73
|
+
INclude for INstances, Extend for sElf\n\nFor all you ever wanted to know about
|
|
74
|
+
constant lookup, see:\nhttp://cirw.in/blog/constant-lookup\n"
|
|
75
|
+
Ruby Global $-v (DollarDashv): ! 'Aliased to $VERBOSE
|
|
76
|
+
|
|
77
|
+
'
|
|
78
|
+
! 'Ruby Keyword: when': ! 'Specific condition of a `case` statement. (See: case)
|
|
79
|
+
|
|
80
|
+
'
|
|
81
|
+
Ruby Global $-W (DollarDashW): ! 'The $-W global ...pry-docmore TODO!
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
Please update https://github.com/rking/pry-docmore/wiki/Ruby-Global-$-W-(DollarDashW)
|
|
85
|
+
|
|
86
|
+
'
|
|
87
|
+
! 'Ruby Keyword: for': ! "A fairly rarely used keyword in Ruby, because we like to
|
|
88
|
+
write the Enumerable\non the left side to remind us that we're not programming in
|
|
89
|
+
some other lanuage.\n\nBut, actually, it is a golf win:\n\n (2..5).each do |i|\n
|
|
90
|
+
\ p i\n end\n\nIs equivalent to:\n\n for i in 2..5\n p i\n end\n"
|
|
91
|
+
Ruby Global $-a (DollarDasha): ! 'The $-a global is true if option -a is set.
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
This is a read-only variable.
|
|
95
|
+
|
|
96
|
+
'
|
|
97
|
+
! 'Ruby Keyword: def': ! 'Define a method.
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
# TODO:
|
|
101
|
+
|
|
102
|
+
# Describe various signatures
|
|
103
|
+
|
|
104
|
+
# def foo
|
|
105
|
+
|
|
106
|
+
# def foo arg
|
|
107
|
+
|
|
108
|
+
# def foo arg, arg2
|
|
109
|
+
|
|
110
|
+
# def foo *args
|
|
111
|
+
|
|
112
|
+
# def foo arg, *args, arg3
|
|
113
|
+
|
|
114
|
+
# …Ruby 2.0 keyword args?
|
|
115
|
+
|
|
116
|
+
# Talk about eigenclasses
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
Doesn''t work inside another `def`, but can work inside blocks. Compare to
|
|
120
|
+
|
|
121
|
+
Module#define_method, which is capable of doing more dynamic tricks.
|
|
122
|
+
|
|
123
|
+
'
|
|
124
|
+
Ruby Global $LOADED_FEATURES (DollarLOADEDUnderscoreFEATURES): ! 'Aliased to $"
|
|
125
|
+
|
|
126
|
+
'
|
|
127
|
+
Ruby Global $6 (DollarSix): ! 'The $6 global is the 6th group of the last successful
|
|
128
|
+
match. May be > 1.
|
|
129
|
+
|
|
130
|
+
'
|
|
131
|
+
Ruby Global $' (DollarTick): ! "The $' global is the string to the right of the last
|
|
132
|
+
successful match.\n\nIf you do this:\n\n str = 'hello goodbye'; str[/good/]\n\nThen
|
|
133
|
+
this:\n\n [ $`, $&, $' ]\n\nYields this:\n\n [\n \"hello \",\n \"good\",\n
|
|
134
|
+
\ \"bye\"\n ]\n"
|
|
135
|
+
Ruby Global $> (DollarGreaterthan): ! 'The $> global is the default output for print,
|
|
136
|
+
printf. $stdout by default.
|
|
137
|
+
|
|
138
|
+
'
|
|
139
|
+
! 'Ruby Keyword: if': ! 'That most fundamental of computing tools.
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
See: https://en.wikipedia.org/wiki/Turing_completeness
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
But also see: http://www.refactoring.com/catalog/replaceConditionalWithPolymorphism.html
|
|
146
|
+
|
|
147
|
+
'
|
|
148
|
+
Ruby Global $\ (DollarBackslash): ! 'The $\ global is the output record separator
|
|
149
|
+
for the print and IO#write.
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
Default is nil.
|
|
153
|
+
|
|
154
|
+
'
|
|
155
|
+
! 'Ruby Keyword: class': ! '- Opens a class definition
|
|
156
|
+
|
|
157
|
+
- class << self ← Opens the eigenclass of ''self''
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
TODO - https://github.com/rking/pry-docmore/wiki
|
|
161
|
+
|
|
162
|
+
'
|
|
163
|
+
! 'Ruby Keyword: not': ! "Boolean negation.\n\n if not x\n\nis equivalent to:\n\n
|
|
164
|
+
\ unless x\n\nNote that the precedence is lower than for `!`. # TODO: elaborate,
|
|
165
|
+
w/ examples.\nSee: http://phrogz.net/ProgrammingRuby/language.html#table_18.4\n"
|
|
166
|
+
Ruby Global $` (DollarBacktick): ! "The $` global is the string to the left of the
|
|
167
|
+
last successful match.\n\nIf you do this:\n\n str = 'hello goodbye'; str[/good/]\n\nThen
|
|
168
|
+
this:\n\n [ $`, $&, $' ]\n\nYields this:\n\n [\n \"hello \",\n \"good\",\n
|
|
169
|
+
\ \"bye\"\n ]\n"
|
|
170
|
+
! 'Ruby Keyword: redo': ! "Jump back to the top of the inner-most block. E.g.:\n\n
|
|
171
|
+
\ 2.times do |i|\n 3.times do |j|\n print i,j\n j += 1\n redo
|
|
172
|
+
if 1 == j\n end\n end\n puts\n\nPrints:\n\n 0001010210111112\n\n#
|
|
173
|
+
TODO: Pick a better example\n"
|
|
174
|
+
Ruby Global $-l (DollarDashl): ! 'The $-l global is true if option -l is set.
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
Read-only variable.
|
|
178
|
+
|
|
179
|
+
'
|
|
180
|
+
! 'Ruby Keyword: until': ! "Negated `while`.\n\n puts 'Guess a letter.'\n until
|
|
181
|
+
'y' == $stdin.readline.chomp\n puts 'Guess again.'\n end\n"
|
|
182
|
+
! 'Ruby Keyword: BEGIN': ! "Like Perl and Awk before that, defines a block to be run
|
|
183
|
+
before the others:\n\n p 3\n BEGIN { p 1 }\n p 4\n BEGIN { p 2 }\n #
|
|
184
|
+
…prints these out as 1, 2, 3, 4\n\nThis works because the whole file gets parsed
|
|
185
|
+
at the beginning (even though\n'class' and 'def' lines are not executed early),
|
|
186
|
+
so the interpreter can reorder\nthese statements.\n\nSee also: `END`\n(Not to be
|
|
187
|
+
confused with lower-case `begin`)\n"
|
|
188
|
+
! 'Ruby Keyword: undef': ! "Opposite of `def` — removes a method definition.\n\n def
|
|
189
|
+
foo; end\n undef foo\n foo ⇒ NameError: undefined local variable or method `foo'
|
|
190
|
+
for main:Object`\n"
|
|
191
|
+
Ruby Global $DEBUG (DollarDEBUG): ! 'The $DEBUG global is the status of the -d switch.
|
|
192
|
+
|
|
193
|
+
'
|
|
194
|
+
Ruby Global $4 (DollarFour): ! 'The $4 global is the 4th group of the last successful
|
|
195
|
+
match. May be > 1.
|
|
196
|
+
|
|
197
|
+
'
|
|
198
|
+
! 'Ruby Keyword: return': ! "Leave the current method, making the given value.\n\nKeep
|
|
199
|
+
in mind that the last statement in a Ruby method is its implied value, so\nthese
|
|
200
|
+
are equivalent:\n\n def f x\n if 0 == x % 3\n return true\n else\n
|
|
201
|
+
\ return false\n end\n end\n\n def f x\n if 0 == x % 3\n true\n
|
|
202
|
+
\ else\n false\n end\n end\n\n…but, then, you might as well go
|
|
203
|
+
all the way with it, as this is equivalent:\n\n def f x\n 0 == x % 3\n end\n\nSo,
|
|
204
|
+
usually, it's only useful as an \"early return\" in Ruby, such as:\n\n return
|
|
205
|
+
if arg > 3\n # rest of method here\n\nNote that you can return out of lambdas
|
|
206
|
+
but not proc's, e.g.:\n\n -> { return 3 }.()\n # ⇒ 3\n proc { return 3
|
|
207
|
+
}.()\n # ⇒ LocalJumpError: unexpected return\n"
|
|
208
|
+
Ruby Global $2 (DollarTwo): ! 'The $2 global is the 2nd group of the last successful
|
|
209
|
+
match. May be > 1.
|
|
210
|
+
|
|
211
|
+
'
|
|
212
|
+
! 'Ruby Keyword: false': ! "In Ruby, only `false` and `nil` evaluate to false.\n\n
|
|
213
|
+
\ def false_check x\n return if nil == x\n return if false == x\n unless
|
|
214
|
+
x\n puts \"This will never ever get reached.\"\n end\n end\n"
|
|
215
|
+
Ruby Global $-i (DollarDashi): ! 'The $-i global represents in-place-edit mode, this
|
|
216
|
+
variable holds the extension, otherwise nil.
|
|
217
|
+
|
|
218
|
+
'
|
|
219
|
+
Ruby Global $! (DollarBang): ! "The $! global is the Exception set by 'rescue'\n\nThis
|
|
220
|
+
code:\n\n begin\n raise 'hi'\n rescue\n p $!\n end\n p $!\n\nPrints
|
|
221
|
+
this:\n\n #<RuntimeError: hi>\n nil\n"
|
|
222
|
+
Ruby Global $= (DollarEquals): ! 'In older versions of Ruby, setting $= allowed case-insensitive
|
|
223
|
+
comparisons;
|
|
224
|
+
|
|
225
|
+
this is now deprecated in favor of using String#casecmp
|
|
226
|
+
|
|
227
|
+
'
|
|
228
|
+
Ruby Global $; (DollarSemicolon): ! 'The $; global is the separator for String#split
|
|
229
|
+
(defaults to nil, which splits on whitespace).
|
|
230
|
+
|
|
231
|
+
'
|
|
232
|
+
! 'Ruby Keyword: break': ! "Hops out of the inner-most loop. Like this:\n\n %w(a
|
|
233
|
+
b c).each do |i|\n print i\n 32343.times do |j|\n break if j >
|
|
234
|
+
2\n print j\n end\n end\n puts\n\nPrints:\n\n a012b012c012\n\nAlso
|
|
235
|
+
note that the keyword accepts an argument:\n\n x = loop do break 3 end\n p
|
|
236
|
+
x\n # ⇒ 3\n\nCompare with: next, last\n"
|
|
237
|
+
Ruby Global $7 (DollarSeven): ! 'The $7 global is the 7th group of the last successful
|
|
238
|
+
match. May be > 1.
|
|
239
|
+
|
|
240
|
+
'
|
|
241
|
+
Ruby Global $-d (DollarDashd): ! 'Aliased to $DEBUG
|
|
242
|
+
|
|
243
|
+
'
|
|
244
|
+
Ruby Global $-F (DollarDashF): ! 'Aliased to $;
|
|
245
|
+
|
|
246
|
+
'
|
|
247
|
+
! 'Ruby Keyword: defined?': ! " defined? nil ⇒ \"nil\"\n defined? self ⇒ \"self\"\n
|
|
248
|
+
\ defined? true ⇒ \"true\"\n defined? false ⇒ \"false\"\n defined? \"asdf\"
|
|
249
|
+
⇒ \"expression\"\n defined? a = 3 ⇒ \"assignment\" # but doesn't actually set
|
|
250
|
+
a to 3.\n defined? printf ⇒ \"method\"\n printf = 3\n defined? printf ⇒
|
|
251
|
+
\"local-variable\" # nil if there is no local or method with that name\n defined?
|
|
252
|
+
$foo ⇒ \"global-variable\" # nil if $foo has not been assigned to\n defined?
|
|
253
|
+
Object ⇒ \"constant\" # nil if there is no constant with that name\n defined?
|
|
254
|
+
super ⇒ \"super\" # nil if there is no super method.\n defined? yield
|
|
255
|
+
⇒ \"yield\" # nil if no block was passed to this method\n\ndefined? is
|
|
256
|
+
most often used to determine whether a constant or global variable is defined. For
|
|
257
|
+
example ruby-1.8.7 didn't have a RUBY_ENGINE constant, so jruby was often detected
|
|
258
|
+
using:\n\n defined?(RUBY_ENGINE) && RUBY_ENGINE == \"jruby\"\n\nAnother idiomatic
|
|
259
|
+
use is to safely call a super-method:\n\n super if defined?(super)\n\nIt can
|
|
260
|
+
be used to detect whether a block was passed to this method, though `block_given?`
|
|
261
|
+
is usually preferred.\n\n yield if defined?(yield)\n\nAlthough the return value
|
|
262
|
+
of `defined?` is a string, this is usually ignored and only the truthiness of the
|
|
263
|
+
result considered.\n\nImprove these docs at https://github.com/rking/pry-docmore/wiki"
|
|
264
|
+
! 'Ruby Keyword: __FILE__': ! "The filename of the code being evaluated. Evaluates
|
|
265
|
+
to \"(pry)\" within the REPL.\n\nUseful especially for code to locate parts nearby,
|
|
266
|
+
such as:\n\n File.dirname(__FILE__)\n"
|
|
267
|
+
Home: ! "This is the input for the actual gem. Edit these, and the next time the
|
|
268
|
+
gem\npushes, this info goes with it.\n\nThe goal is for this to be an informative
|
|
269
|
+
set of docs, full of anything you can\nthink to add, so don't hold back.\n\n- [Ruby
|
|
270
|
+
Global $1 (DollarOne)](wiki/Ruby Global $1 (DollarOne\\)) | [Ruby Global $2\n (DollarTwo)](wiki/Ruby
|
|
271
|
+
Global $2 (DollarTwo\\)) | [Ruby Global $3 (DollarThree)](wiki/Ruby Global $3 (DollarThree\\))
|
|
272
|
+
| [Ruby Global $4 (DollarFour)](wiki/Ruby Global $4 (DollarFour\\)) | [Ruby Global
|
|
273
|
+
$5 (DollarFive)](wiki/Ruby Global $5 (DollarFive\\)) | [Ruby Global $6 (DollarSix)](wiki/Ruby
|
|
274
|
+
Global $6 (DollarSix\\)) | [Ruby Global $7 (DollarSeven)](wiki/Ruby Global $7 (DollarSeven\\))
|
|
275
|
+
| [Ruby Global $8 (DollarEight)](wiki/Ruby Global $8 (DollarEight\\)) | [Ruby Global
|
|
276
|
+
$9 (DollarNine)](wiki/Ruby Global $9 (DollarNine\\))\n- [Ruby Global $& (DollarAmpersand)](wiki/Ruby
|
|
277
|
+
Global $& (DollarAmpersand\\))\n- [Ruby Global $@ (DollarAt)](wiki/Ruby Global $@
|
|
278
|
+
(DollarAt\\))\n- [Ruby Global $` (DollarBacktick)](wiki/Ruby Global $` (DollarBacktick\\))\n-
|
|
279
|
+
[Ruby Global $! (DollarBang)](wiki/Ruby Global $! (DollarBang\\))\n- [Ruby Global
|
|
280
|
+
$= (DollarEquals)](wiki/Ruby Global $= (DollarEquals\\))\n- [Ruby Global $+ (DollarPlus)](wiki/Ruby
|
|
281
|
+
Global $+ (DollarPlus\\))\n- [Ruby Global $⁄ (DollarSlash)](wiki/Ruby Global $⁄
|
|
282
|
+
(DollarSlash\\))\n- [Ruby Global $~ (DollarSquiggle)](wiki/Ruby Global $~ (DollarSquiggle\\))\n-
|
|
283
|
+
[Ruby Global $' (DollarTick)](wiki/Ruby Global $' (DollarTick\\))\n- [Ruby Global
|
|
284
|
+
$KCODE (DollarKCODE)](wiki/Ruby Global $KCODE (DollarKCODE\\))\n- [Ruby Global $-K
|
|
285
|
+
(DollarDashK)](wiki/Ruby Global $-K (DollarDashK\\))\n- [Ruby Global $LOADED\\_FEATURES
|
|
286
|
+
(DollarLOADEDUnderscoreFEATURES)](wiki/Ruby Global $LOADED\\_FEATURES (DollarLOADEDUnderscoreFEATURES\\))\n-
|
|
287
|
+
[Ruby Global $PROGRAM\\_NAME (DollarPROGRAMUnderscoreNAME)](wiki/Ruby Global $PROGRAM\\_NAME
|
|
288
|
+
(DollarPROGRAMUnderscoreNAME\\))\n- [Ruby Global $-W (DollarDashW)](wiki/Ruby Global
|
|
289
|
+
$-W (DollarDashW\\))\n- [Ruby Global $\\\" (DollarQuote)](wiki/Ruby Global $\\\"
|
|
290
|
+
(DollarQuote\\))\n- [Ruby Global $$ (DollarDollar)](wiki/Ruby Global $$ (DollarDollar\\))\n-
|
|
291
|
+
[Ruby Global $* (DollarStar)](wiki/Ruby Global $* (DollarStar\\))\n- [Ruby Global
|
|
292
|
+
$, (DollarComma)](wiki/Ruby Global $, (DollarComma\\))\n- [Ruby Global $-0 (DollarDashZero)](wiki/Ruby
|
|
293
|
+
Global $-0 (DollarDashZero\\))\n- [Ruby Global $-F (DollarDashF)](wiki/Ruby Global
|
|
294
|
+
$-F (DollarDashF\\))\n- [Ruby Global $-I (DollarDashI)](wiki/Ruby Global $-I (DollarDashI\\))\n-
|
|
295
|
+
[Ruby Global $-a (DollarDasha)](wiki/Ruby Global $-a (DollarDasha\\))\n- [Ruby Global
|
|
296
|
+
$-d (DollarDashd)](wiki/Ruby Global $-d (DollarDashd\\))\n- [Ruby Global $-i (DollarDashi)](wiki/Ruby
|
|
297
|
+
Global $-i (DollarDashi\\))\n- [Ruby Global $-l (DollarDashl)](wiki/Ruby Global
|
|
298
|
+
$-l (DollarDashl\\))\n- [Ruby Global $-p (DollarDashp)](wiki/Ruby Global $-p (DollarDashp\\))\n-
|
|
299
|
+
[Ruby Global $-v (DollarDashv)](wiki/Ruby Global $-v (DollarDashv\\))\n- [Ruby Global
|
|
300
|
+
$-w (DollarDashw)](wiki/Ruby Global $-w (DollarDashw\\))\n- [Ruby Global $. (DollarDot)](wiki/Ruby
|
|
301
|
+
Global $. (DollarDot\\))\n- [Ruby Global $0 (DollarZero)](wiki/Ruby Global $0 (DollarZero\\))\n-
|
|
302
|
+
[Ruby Global $: (DollarColon)](wiki/Ruby Global $: (DollarColon\\))\n- [Ruby Global
|
|
303
|
+
$; (DollarSemicolon)](wiki/Ruby Global $; (DollarSemicolon\\))\n- [Ruby Global $<
|
|
304
|
+
(DollarLessthan)](wiki/Ruby Global $< (DollarLessthan\\))\n- [Ruby Global $> (DollarGreaterthan)](wiki/Ruby
|
|
305
|
+
Global $> (DollarGreaterthan\\))\n- [Ruby Global $? (Dollar?)](wiki/Ruby Global
|
|
306
|
+
$? (Dollar?\\))\n- [Ruby Global $DEBUG (DollarDEBUG)](wiki/Ruby Global $DEBUG (DollarDEBUG\\))\n-
|
|
307
|
+
[Ruby Global $FILENAME (DollarFILENAME)](wiki/Ruby Global $FILENAME (DollarFILENAME\\))\n-
|
|
308
|
+
[Ruby Global $LOAD_PATH (DollarLOADUnderscorePATH)](wiki/Ruby Global $LOAD_PATH
|
|
309
|
+
(DollarLOADUnderscorePATH\\))\n- [Ruby Global $VERBOSE (DollarVERBOSE)](wiki/Ruby
|
|
310
|
+
Global $VERBOSE (DollarVERBOSE\\))\n- [Ruby Global $\\\\ (DollarBackslash)](wiki/Ruby
|
|
311
|
+
Global $\\\\ (DollarBackslash\\))\n- [Ruby Global $_ (DollarUnderscore)](wiki/Ruby
|
|
312
|
+
Global $_ (DollarUnderscore\\))\n- [Ruby Global $stderr (Dollarstderr)](wiki/Ruby
|
|
313
|
+
Global $stderr (Dollarstderr\\))\n- [Ruby Global $stdin (Dollarstdin)](wiki/Ruby
|
|
314
|
+
Global $stdin (Dollarstdin\\))\n- [Ruby Global $stdout (Dollarstdout)](wiki/Ruby
|
|
315
|
+
Global $stdout (Dollarstdout\\))\n\n…\n\n- [Ruby Keyword: alias](wiki/Ruby Keyword%3A
|
|
316
|
+
alias)\n- [Ruby Keyword: and](wiki/Ruby Keyword%3A and)\n- [Ruby Keyword: begin](wiki/Ruby
|
|
317
|
+
Keyword%3A begin)\n- [Ruby Keyword: BEGIN](wiki/Ruby Keyword%3A BEGIN)\n- [Ruby
|
|
318
|
+
Keyword: break](wiki/Ruby Keyword%3A break)\n- [Ruby Keyword: case](wiki/Ruby Keyword%3A
|
|
319
|
+
case)\n- [Ruby Keyword: class](wiki/Ruby Keyword%3A class)\n- [Ruby Keyword: defined?](wiki/Ruby
|
|
320
|
+
Keyword%3A defined?)\n- [Ruby Keyword: def](wiki/Ruby Keyword%3A def)\n- [Ruby Keyword:
|
|
321
|
+
do](wiki/Ruby Keyword%3A do)\n- [Ruby Keyword: else](wiki/Ruby Keyword%3A else)\n-
|
|
322
|
+
[Ruby Keyword: elsif](wiki/Ruby Keyword%3A elsif)\n- [Ruby Keyword: \\_\\_ENCODING\\_\\_](wiki/Ruby
|
|
323
|
+
Keyword%3A \\_\\_ENCODING\\_\\_)\n- [Ruby Keyword: end](wiki/Ruby Keyword%3A end)\n-
|
|
324
|
+
[Ruby Keyword: END](wiki/Ruby Keyword%3A END)\n- [Ruby Keyword: ensure](wiki/Ruby
|
|
325
|
+
Keyword%3A ensure)\n- [Ruby Keyword: false](wiki/Ruby Keyword%3A false)\n- [Ruby
|
|
326
|
+
Keyword: \\_\\_FILE\\_\\_](wiki/Ruby Keyword%3A \\_\\_FILE\\_\\_)\n- [Ruby Keyword:
|
|
327
|
+
for](wiki/Ruby Keyword%3A for)\n- [Ruby Keyword: if](wiki/Ruby Keyword%3A if)\n-
|
|
328
|
+
[Ruby Keyword: in](wiki/Ruby Keyword%3A in)\n- [Ruby Keyword: \\_\\_LINE\\_\\_](wiki/Ruby
|
|
329
|
+
Keyword%3A \\_\\_LINE\\_\\_)\n- [Ruby Keyword: module](wiki/Ruby Keyword%3A module)\n-
|
|
330
|
+
[Ruby Keyword: next](wiki/Ruby Keyword%3A next)\n- [Ruby Keyword: nil](wiki/Ruby
|
|
331
|
+
Keyword%3A nil)\n- [Ruby Keyword: not](wiki/Ruby Keyword%3A not)\n- [Ruby Keyword:
|
|
332
|
+
or](wiki/Ruby Keyword%3A or)\n- [Ruby Keyword: redo](wiki/Ruby Keyword%3A redo)\n-
|
|
333
|
+
[Ruby Keyword: rescue](wiki/Ruby Keyword%3A rescue)\n- [Ruby Keyword: retry](wiki/Ruby
|
|
334
|
+
Keyword%3A retry)\n- [Ruby Keyword: return](wiki/Ruby Keyword%3A return)\n- [Ruby
|
|
335
|
+
Keyword: self](wiki/Ruby Keyword%3A self)\n- [Ruby Keyword: super](wiki/Ruby Keyword%3A
|
|
336
|
+
super)\n- [Ruby Keyword: then](wiki/Ruby Keyword%3A then)\n- [Ruby Keyword: true](wiki/Ruby
|
|
337
|
+
Keyword%3A true)\n- [Ruby Keyword: undef](wiki/Ruby Keyword%3A undef)\n- [Ruby Keyword:
|
|
338
|
+
unless](wiki/Ruby Keyword%3A unless)\n- [Ruby Keyword: until](wiki/Ruby Keyword%3A
|
|
339
|
+
until)\n- [Ruby Keyword: when](wiki/Ruby Keyword%3A when)\n- [Ruby Keyword: while](wiki/Ruby
|
|
340
|
+
Keyword%3A while)\n- [Ruby Keyword: yield](wiki/Ruby Keyword%3A yield)\n"
|
|
341
|
+
Ruby Global $8 (DollarEight): ! 'The $8 global is the 8th group of the last successful
|
|
342
|
+
match. May be > 1.
|
|
343
|
+
|
|
344
|
+
'
|
|
345
|
+
Ruby Global $9 (DollarNine): ! 'The $9 global is the 9th group of the last successful
|
|
346
|
+
match. May be > 1.
|
|
347
|
+
|
|
348
|
+
'
|
|
349
|
+
! 'Ruby Keyword: retry': ! "Re-run the block that raised an Exception.\n\nFor example:\n\n
|
|
350
|
+
\ tries = 3\n begin\n puts \"Try ##{tries}.\"\n 1/0\n rescue =>
|
|
351
|
+
e\n tries -= 1\n retry unless tries.zero?\n end\n\nThis will output:\n\n
|
|
352
|
+
\ Try #3.\n Try #2.\n Try #1.\n\nSee also: begin, rescue, else, ensure\n"
|
|
353
|
+
Ruby Global $VERBOSE (DollarVERBOSE): ! 'The $VERBOSE global is the verbose flag,
|
|
354
|
+
which is set by the -v switch.
|
|
355
|
+
|
|
356
|
+
'
|
|
357
|
+
! 'Ruby Keyword: rescue': ! "Catch exceptions.\n\nUsage:\n\n begin\n 1/0\n
|
|
358
|
+
\ rescue => e\n puts \"No division by zero ever bothered me.\"\n end\n\nOr\n\n
|
|
359
|
+
\ def foo\n 1/0\n rescue\n puts \"Yep, works on 'def's, too.\"\n
|
|
360
|
+
\ end\n\nThis is the basic exception heirarchy:\n\n Exception\n NoMemoryError\n
|
|
361
|
+
\ ScriptError:\n LoadError\n NotImplementedError\n SyntaxError\n
|
|
362
|
+
\ SignalException\n Interrupt\n StandardError\n ArgumentError\n IOError\n
|
|
363
|
+
\ EOFError\n IndexError\n LocalJumpError\n NameError\n NoMethodError\n
|
|
364
|
+
\ RangeError\n FloatDomainError\n RegexpError\n RuntimeError\n
|
|
365
|
+
\ SecurityError\n SystemCallError\n SystemStackError\n ThreadError\n
|
|
366
|
+
\ TypeError\n ZeroDivisionError\n SystemExit\n fatal\n\nMore in Avdi
|
|
367
|
+
Grimm's book, Exceptional Ruby: http://pragprog.com/book/ager/exceptional-ruby\n#
|
|
368
|
+
TODO:\n# Explain the args syntax\n# Talk about Standard\n\nSee: ensure, else,
|
|
369
|
+
retry\n"
|
|
370
|
+
Ruby Global $-I (DollarDashI): ! 'Aliased to $:
|
|
371
|
+
|
|
372
|
+
'
|
|
373
|
+
! 'Ruby Keyword: elsif': ! 'Is only checked when the preceding `if`/`elsif` conditions
|
|
374
|
+
evaluated false.
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
TODO - https://github.com/rking/pry-docmore/wiki
|
|
378
|
+
|
|
379
|
+
'
|
|
380
|
+
Ruby Global $5 (DollarFive): ! 'The $5 global is the 5th group of the last successful
|
|
381
|
+
match. May be > 1.
|
|
382
|
+
|
|
383
|
+
'
|
|
384
|
+
Ruby Global $0 (DollarZero): ! 'The $0 global contains the name of the script being
|
|
385
|
+
executed. May be assignable.
|
|
386
|
+
|
|
387
|
+
Alias: $PROGRAM_NAME
|
|
388
|
+
|
|
389
|
+
'
|
|
390
|
+
! 'Ruby Keyword: nil': ! 'Represents "nothing whatsoever".
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
Along with `false`, is the other value that evaluates to false in conditionals.
|
|
394
|
+
|
|
395
|
+
'
|
|
396
|
+
! 'Ruby Keyword: true': ! "not false. Everything in Ruby (except `false` and `nil`)
|
|
397
|
+
are true.\n\n if 0\n puts \"Ruby.\"\n else\n puts \"Perl.\"\n end\n"
|
|
398
|
+
! 'Ruby Keyword: super': ! "Call the current method, but using the superclass's implementation.
|
|
399
|
+
Can be\nuseful so that subclasses can 'decorate' their parent class's functionality.\n\nA
|
|
400
|
+
subtle syntax issue is that, when this is called with no arguments, all\narguments
|
|
401
|
+
are passed up.\n\nFor example:\n\n class Dad\n def f *args; p args end\n
|
|
402
|
+
\ end\n class Kid < Dad\n def f *args; super end\n end\n Kid.new.f
|
|
403
|
+
1, 2\n\nOutputs:\n\n [1, 2]\n\nThe way to stop this behavior is to use something
|
|
404
|
+
Ruby almost never requires:\nempty parens:\n\n class Dad\n def f *args;
|
|
405
|
+
p args end\n end\n class Kid < Dad\n def f *args; super() end\n end\n
|
|
406
|
+
\ Kid.new.f 1, 2\n\nOutputs:\n\n []\n"
|
|
407
|
+
! 'Ruby Keyword: alias': ! "The alias keyword is used to make synonyms of methods.\n\n
|
|
408
|
+
\ If you are used to the semantics of the `/bin/ln` command, get it out of your\n
|
|
409
|
+
\ head right now: Ruby does the opposite. That is, instead of `ln existing\n new`,
|
|
410
|
+
Ruby's semantics are `alias new existing`. (Mnested Mnemonic: this `new`\n sorting
|
|
411
|
+
is the b`a`-`n`-`e` of my `exist`ence.)\n\n Also take particular note that this
|
|
412
|
+
is not a method call, but a keyword, so\n it can do things method calls cannot.
|
|
413
|
+
The args are not :symbols (though they\n are permitted to be), and it is a SyntaxError
|
|
414
|
+
to attempt to place a comma\n between the args.\n\n Note that, this being a keyword
|
|
415
|
+
and happening at compile-time, is not enough\n to make dynamic assignments. See
|
|
416
|
+
{Module#alias_method} for that kind of\n trickery.\n\nBasic Usage\n\n def foo;
|
|
417
|
+
3 end\n alias boo foo\n boo\n ⇒ 3\n\nSymbols as args\n\n alias :zoo :boo # or
|
|
418
|
+
even mix and match, if you want to for some reason.\n zoo\n ⇒ 3\n\nSome decorating!\n\n
|
|
419
|
+
\ alias orig_foo foo\n def foo; 4 + orig_foo end\n foo\n ⇒ 7\n # See also Rails's
|
|
420
|
+
alias_method_chain for a formalization of this idiom.\n\nSee also: http://kresimirbojcic.com/2011/12/01/decorators-in-ruby.html\n"
|
|
421
|
+
! 'Ruby Global $: (DollarColon)': ! 'The $: global is the Load path for scripts and
|
|
422
|
+
binary modules by load or require.
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
(After scripts are loaded, their path will be in $" )
|
|
426
|
+
|
|
427
|
+
'
|
|
428
|
+
Ruby Global $-0 (DollarDashZero): ! 'Aliased to $/
|
|
429
|
+
|
|
430
|
+
'
|
|
431
|
+
Ruby Global $? (Dollar?): ! "The $? global is the process status of the last executed
|
|
432
|
+
child process.\n\nIt is of type Process::Status, which implements the following
|
|
433
|
+
methods:\n & == >> coredump? exited? exitstatus inspect pid signaled? stopped?\n
|
|
434
|
+
\ stopsig success? termsig to_i to\n\nFor example:\n\n `head /dev/urandom |
|
|
435
|
+
grep \"Alas, poor Yorick! I knew him, Horatio…\"`\n $?.success?\n # *probably*
|
|
436
|
+
false\n"
|
|
437
|
+
Ruby Global $PROGRAM_NAME (DollarPROGRAMUnderscoreNAME): ! 'The $PROGRAM_NAME global
|
|
438
|
+
contains the name of the script being executed.
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
May be assignable to affect the listing in ''ps'' output.
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
Same as $0
|
|
445
|
+
|
|
446
|
+
'
|
|
447
|
+
Ruby Global $" (DollarQuote): ! 'The $" global is an array containing the module names
|
|
448
|
+
loaded by require.
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
(Compare to the list of lookup paths in `$LOAD_PATH`, a.k.a `$:`)
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
'
|
|
455
|
+
! 'Ruby Keyword: while': ! "Loop as long as the condition holds.\n\n puts 'Guess
|
|
456
|
+
a letter.'\n while 'y' == $stdin.readline.chomp\n puts 'Anything but that
|
|
457
|
+
one.'\n end\n"
|
|
458
|
+
! 'Ruby Keyword: END': ! "Like Perl and Awk before that, defines a block to be run
|
|
459
|
+
after the others:\n\n p 1\n END { p 4 }\n p 2\n END { p 3 }\n # …prints
|
|
460
|
+
these out as 1, 2, 3, 4\n\nSee also: `BEGIN`\n(Not to be confused with lower-case
|
|
461
|
+
`end`)\n"
|
|
462
|
+
Ruby Global $-w (DollarDashw): ! 'The $-w global is true if option -w is set.
|
|
463
|
+
|
|
464
|
+
'
|
|
465
|
+
! 'Ruby Keyword: self': ! "An ever-present variable in Ruby. At the very top level,
|
|
466
|
+
it is the \"(main)\"\nself, but everywhere else its value is very important to know.\n\nWithin
|
|
467
|
+
a method, it is the instance that received the method.\n\nWithin a class defintion,
|
|
468
|
+
it is the class itself. This explains why:\n\n class Foo\n def self.hi;
|
|
469
|
+
'hi' end # this is equivalent to:\n def Foo.hi; 'hi' end # this.\n end\n\n#
|
|
470
|
+
TODO:\n# Explain eigenclasses\n# …?\n"
|
|
471
|
+
Ruby Global $FILENAME (DollarFILENAME): ! 'The $FILENAME global is the current input
|
|
472
|
+
file from $<.
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
Same as $<.filename.
|
|
476
|
+
|
|
477
|
+
'
|
|
478
|
+
Ruby Global $_ (DollarUnderscore): ! 'The $_ global is the last input line of string
|
|
479
|
+
by `gets` or `readline`.
|
|
480
|
+
|
|
481
|
+
'
|
|
482
|
+
! 'Ruby Keyword: and': ! "Boolean conjunction.\n\n Only evaluates to `true` if both
|
|
483
|
+
its left and right side are true.\n\n Remember that the 'and' operator is lower
|
|
484
|
+
precedence operator than '&&', so\n\n an_expression and another_expression\n is
|
|
485
|
+
roughly equivalent to:\n (an_expression) && (another_expression)\n\nTruth table\n\n
|
|
486
|
+
\ true and true ⇒ true\n false and true ⇒ false\n false and false ⇒ false\n\nPrecedence\n\n
|
|
487
|
+
\ true and not false ⇒ true\n true && not false ⇒ SyntaxError\n a = true and false;
|
|
488
|
+
a ⇒ true\n a = true && false; a ⇒ false\n\nThe fowl chain\n\n if false or true
|
|
489
|
+
&& false then false elsif true and false or true then true end\n ⇒ true\n\nSee
|
|
490
|
+
http://phrogz.net/ProgrammingRuby/language.html#table_18.4\n"
|
|
491
|
+
Ruby Global $. (DollarDot): ! 'The $. global is the current input line number of the
|
|
492
|
+
last file that was read.
|
|
493
|
+
|
|
494
|
+
'
|
|
495
|
+
! 'Ruby Keyword: __ENCODING__': ! 'Read-only value of the current Encoding object
|
|
496
|
+
(which has methods:
|
|
497
|
+
|
|
498
|
+
ascii_compatible? dummy? inspect name names replicate to_s)
|
|
499
|
+
|
|
500
|
+
|
|
501
|
+
By default is: #<Encoding:US-ASCII>
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
But can be affected by the 1st or 2nd line of the file being something like:
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
# encoding: utf-8
|
|
508
|
+
|
|
509
|
+
'
|
|
510
|
+
Ruby Global $KCODE (DollarKCODE): ! 'The $KCODE global ...pry-docmore TODO!
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
Please update https://github.com/rking/pry-docmore/wiki/Ruby-Global-$KCODE-(DollarKCODE)
|
|
514
|
+
|
|
515
|
+
'
|
|
516
|
+
! 'Ruby Keyword: ensure': ! 'The sibling of `require` that is run when there is or
|
|
517
|
+
isn''t an exception.
|
|
518
|
+
|
|
519
|
+
'
|
|
520
|
+
Ruby Global $3 (DollarThree): ! 'The $3 global is the 3rd group of the last successful
|
|
521
|
+
match. May be > 1.
|
|
522
|
+
|
|
523
|
+
'
|
|
524
|
+
Ruby Global $1 (DollarOne): ! 'The $1 global is the 1st group of the last successful
|
|
525
|
+
match. May be > 1.
|
|
526
|
+
|
|
527
|
+
'
|
|
528
|
+
Ruby Global $stdin (Dollarstdin): ! 'The $stdin global is the current standard input.
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
This is file descriptor 0, traditionally.
|
|
532
|
+
|
|
533
|
+
'
|
|
534
|
+
! 'Ruby Keyword: yield': ! "Run the block passed to a method.\n\n def foo\n p
|
|
535
|
+
1\n yield 2\n p 3\n end\n foo do |i|\n p i\n end\n\nPrints:\n\n
|
|
536
|
+
\ 1\n 2\n 3\n"
|
|
537
|
+
Ruby Global $+ (DollarPlus): ! "The $+ global is the highest group matched by the
|
|
538
|
+
last successful match.\n\nThis:\n\n str = 'hello goodbye'; str[/he(llo) g(o(od))/];
|
|
539
|
+
$+\n\nShows:\n\n \"od\"\n"
|
|
540
|
+
Ruby Global $$ (DollarDollar): ! "The $$ global is the process number of the Ruby
|
|
541
|
+
running this script.\n\nCan be used for process control tricks, such as recording
|
|
542
|
+
in a \"pidfile\" so\nother processes can later kill the current one, or accessing
|
|
543
|
+
\"/proc/#$$\" on\nsystems (such as Linux) having a mounted procfs.\n\nTraditionally
|
|
544
|
+
used in shell scripts for a quick way to generate a semi-unique\ntemp filename,
|
|
545
|
+
but this is better achieved like:\n\n require 'tempfile'\n t = Tempfile.new
|
|
546
|
+
'hi'\n # produces a file like: /tmp/hi20121119-2774-1buu566 (because $$ == 2774)\n"
|
|
547
|
+
Ruby Global $LOAD_PATH (DollarLOADUnderscorePATH): ! 'Aliased to $:
|
|
548
|
+
|
|
549
|
+
'
|
|
550
|
+
! 'Ruby Keyword: unless': ! "Equivalent to `if not`, but with very clear precedence.
|
|
551
|
+
Especially popular in\nthe \"Yoda if\" form:\n\n fail \"Oh no!\" unless valid?\n"
|
|
552
|
+
Ruby Global $-K (DollarDashK): ! 'The $-K global ...pry-docmore TODO!
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
Please update https://github.com/rking/pry-docmore/wiki/Ruby-Global-$-K-(DollarDashK)
|
|
556
|
+
|
|
557
|
+
'
|
|
558
|
+
Ruby Global $~ (DollarSquiggle): ! 'The $~ global is the match-data about the last
|
|
559
|
+
match in the current scope.
|
|
560
|
+
|
|
561
|
+
'
|
|
562
|
+
! 'Ruby Keyword: in': ! 'Goes with the `for` keyword.
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
# Anything else? If so, let us know: https://github.com/rking/pry-docmore/wiki
|
|
566
|
+
|
|
567
|
+
'
|
|
568
|
+
Ruby Global $stderr (Dollarstderr): ! 'The $stderr global is the current standard
|
|
569
|
+
error output.
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
This is file descriptor 2, traditionally.
|
|
573
|
+
|
|
574
|
+
'
|
|
575
|
+
! 'Ruby Keyword: end': ! 'The single biggest wart in the Ruby syntax (because sleeker
|
|
576
|
+
languages, such as
|
|
577
|
+
|
|
578
|
+
CoffeeScript, imply it by indentation.)
|
|
579
|
+
|
|
580
|
+
'
|
|
581
|
+
! 'Ruby Keyword: else': ! 'The part of a condition that happens when none if the `if`
|
|
582
|
+
or `elsif` parts
|
|
583
|
+
|
|
584
|
+
hold true. Also works with `case` and `rescue`.
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
TODO - https://github.com/rking/pry-docmore/wiki
|
|
588
|
+
|
|
589
|
+
'
|
|
590
|
+
! 'Ruby Keyword: then': ! "A keyword that is generally needless. For example, these
|
|
591
|
+
all work:\n\n if 3 then\n puts 'hi'\n end\n if 3\n puts 'hi'\n
|
|
592
|
+
\ end\n\n if 3 then 'yes' else 'no' end\n if 3; 'yes' else 'no' end\n 3
|
|
593
|
+
? 'yes' : 'no'\n\n case x\n when 3 then puts 'yo' end\n when 4; puts 'yo'
|
|
594
|
+
end\n end\n"
|
|
595
|
+
Ruby Global $* (DollarStar): ! 'The $* global is the ARGV, the command line arguments
|
|
596
|
+
given for the script.
|
|
597
|
+
|
|
598
|
+
'
|
|
599
|
+
Ruby Global $& (DollarAmpersand): ! "The $& global is the string matched by the last
|
|
600
|
+
successful match.\n\nIf you do this:\n\n str = 'hello goodbye'; str[/good/]\n\nThen
|
|
601
|
+
this:\n\n [ $`, $&, $' ]\n\nYields this:\n\n [\n \"hello \",\n \"good\",\n
|
|
602
|
+
\ \"bye\"\n ]\n"
|
|
603
|
+
Ruby Global $SAFE (DollarSAFE): ! 'This variable determines the "level of paranoia",
|
|
604
|
+
restricting the set of legal
|
|
605
|
+
|
|
606
|
+
operations.
|
|
607
|
+
|
|
608
|
+
|
|
609
|
+
See: http://www.ruby-doc.org/docs/ProgrammingRuby/html/taint.html
|
|
610
|
+
|
|
611
|
+
'
|
|
612
|
+
Ruby Global $⁄ (DollarSlash): ! 'The $/ global is the input record separator, newline
|
|
613
|
+
by default.
|
|
614
|
+
|
|
615
|
+
|
|
616
|
+
This affects String#each_lines, String#lines, and String#chomp
|
|
617
|
+
|
|
618
|
+
'
|