forked from zenspider/seattlerailsbridge
/
03.yaml
67 lines (48 loc) · 2.27 KB
/
03.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
---
content: |
## Other Tools to help you learn Ruby
### ri
ri is a tool to look up ruby documentation:
$ ri String.split
= String.split
(from ruby core)
------------------------------------------------------------------------------
str.split(pattern=$;, [limit]) => anArray
------------------------------------------------------------------------------
Divides str into substrings based on a delimiter, returning an array of
these substrings.
...
You can do a lot with it:
* `ri Class` -- looks up the class documentation and shows all the methods available.
* `ri Class.method` -- looks up a specific method on a class or module.
* `ri method` -- searches all classes for matching methods
If running ri doesn't work and you've installed ruby using rvm, try
running this command first:
$ rvm docs generate
### irb
We've already introduced irb above, but it can't be stressed enough
that having an interactive live session with ruby is invaluable. You
can learn a lot from it.
Add this to a file called ~/.irbrc:
<pre class="code">
:::ruby
class Object
def pim inherited = false
self.class.public_instance_methods(inherited).sort -
Object.public_instance_methods
end
end
</pre>
Now you can do stuff like:
$ irb
>> "blah".pim
=> ["%", "*", "+", "<<", "<=>", "[]", "[]=", "bytes", "bytesize", ...]
All of these methods are available for any string. You can then use
`ri` to look up the method documentation. It is a great way to find goodies!
### online resources
* [Ruby Quickref](http://www.zenspider.com/Languages/Ruby/QuickRef.html)
* The Google - searching "ruby" and whatever you're looking for usually leads to good stuff.
* [Ruby Koans](http://rubykoans.com/) - a great set of lessons in an interactive form.
* [Learn to Program by Chris Pine](http://pine.fm/LearnToProgram) - also available as [a book](http://pragprog.com/book/ltp2/learn-to-program).
* [The Pickaxe](http://pragprog.com/book/ruby3/programming-ruby-1-9) - The definitive ruby reference (and has a great tutorial too).
* [Why's (poignant) Guide to Ruby](http://www.scribd.com/doc/8545174/whys-Poignant-Guide-to-Ruby) - the (crazy) guide to ruby... Try it, you might like it.