pry-docmore 0.0.2 → 0.0.3
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.
@@ -1,3 +1,30 @@
|
|
1
|
-
|
1
|
+
Usage: module ModuleName; module-contents end
|
2
2
|
|
3
|
-
|
3
|
+
Defines a new Module, or re-opens an existing module. Modules in ruby are
|
4
|
+
collections of code, they have two distinct use-cases:
|
5
|
+
|
6
|
+
1. As a Namespace. Often all of the code in a rubygem will be written in the
|
7
|
+
same module to avoid naming collisions with code not in that Gem.
|
8
|
+
|
9
|
+
2. As a set of shared functions. Modules can be included into Classes, which
|
10
|
+
makes all of the methods defined in the module available to instances of the
|
11
|
+
class. This can be used to emulate multiple-inheritance, or to divide one large
|
12
|
+
class into more manageable chunks.
|
13
|
+
|
14
|
+
Note that, though the class `Class` inherits from `Module`, this is more of an
|
15
|
+
implementation detail than a direct, Liskov-substitutable interface: modules
|
16
|
+
can be `include`d, `extend`ed or `using`d, while classes cannot. (On the other
|
17
|
+
hand, classes can be instantiated, where modules cannot).
|
18
|
+
|
19
|
+
module X
|
20
|
+
def foo; 2 end
|
21
|
+
end
|
22
|
+
class Y; include X end
|
23
|
+
class Z; extend X end
|
24
|
+
# Now, these work:
|
25
|
+
Y.new.foo
|
26
|
+
Z.foo
|
27
|
+
# Mnemonic! INclude for INstances, Extend for sElf
|
28
|
+
|
29
|
+
For all you ever wanted to know about constant lookup, see:
|
30
|
+
http://cirw.in/blog/constant-lookup
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry-docmore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: pry
|