pry-docmore 0.0.3 → 0.0.4

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 +1,2 @@
1
- The $0 global Same as $PROGRAM_NAME. Contains the name of the script being executed. May be assignable.
1
+ The $0 global contains the name of the script being executed. May be assignable.
2
+ Alias: $PROGRAM_NAME
@@ -2,12 +2,28 @@
2
2
  defined? self ⇒ "self"
3
3
  defined? true ⇒ "true"
4
4
  defined? false ⇒ "false"
5
- # ____ ⇒ "expression"
5
+ defined? "asdf" ⇒ "expression"
6
+ defined? a = 3 ⇒ "assignment" # but doesn't actually set a to 3.
6
7
  defined? printf ⇒ "method"
7
8
  printf = 3
8
- defined? printf ⇒ "local-variable"
9
- defined? a = 3 ⇒ "assignment" # but doesn't actually set a to 3.
9
+ defined? printf ⇒ "local-variable" # nil if there is no local or method with that name
10
+ defined? $foo ⇒ "global-variable" # nil if $foo has not been assigned to
11
+ defined? Object ⇒ "constant" # nil if there is no constant with that name
12
+ defined? super ⇒ "super" # nil if there is no super method.
13
+ defined? yield ⇒ "yield" # nil if no block was passed to this method
14
+
15
+ defined? is most often used to determine whether a constant or global variable is defined. For example ruby-1.8.7 didn't have a RUBY_ENGINE constant, so jruby was often detected using:
16
+
17
+ defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
18
+
19
+ Another idiomatic use is to safely call a super-method:
20
+
21
+ super if defined?(super)
22
+
23
+ It can be used to detect whether a block was passed to this method, though `block_given?` is usually preferred.
24
+
25
+ yield if defined?(yield)
10
26
 
11
- What the heck is this thing good for?
27
+ Although the return value of `defined?` is a string, this is usually ignored and only the truthiness of the result considered.
12
28
 
13
- Please answer at: https://github.com/rking/pry-docmore/wiki
29
+ Improve these docs at https://github.com/rking/pry-docmore/wiki
@@ -24,7 +24,8 @@ hand, classes can be instantiated, where modules cannot).
24
24
  # Now, these work:
25
25
  Y.new.foo
26
26
  Z.foo
27
- # Mnemonic! INclude for INstances, Extend for sElf
27
+ # "extend just calls include on the eigenclass"
28
+ # Mnemonic! INclude for INstances, Extend for sElf
28
29
 
29
30
  For all you ever wanted to know about constant lookup, see:
30
31
  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.3
4
+ version: 0.0.4
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-22 00:00:00.000000000 Z
12
+ date: 2013-01-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pry