Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Preview
Start a free Courses trial
to watch this video
Ruby Core contains the classes and modules that come with Ruby and make Ruby work. For example, Ruby Core contains many familiar classes that you have worked with so far: Array, Hash, Fixnum, and more.
Links
Ruby Core contains the classes and modules
that come with Ruby and make Ruby work.
0:05
For example, Ruby Core contains many
familiar classes that you've worked with
0:10
so far, things like Array,
Hash, Fixnum, and more.
0:15
Let's take a look at some of what Ruby
Core has to offer now using workspaces.
0:21
So here is the Ruby Core documentation.
0:26
Now, you'll find a link to this in
the notes right below the video.
0:29
So, you can go ahead and
look that up and follow along.
0:34
Now, when we look at the documentation,
on the left side here, right on top,
0:37
the first thing that we
have is a list of files.
0:41
This documentation format is
relatively standard for Ruby Core,
0:45
standard library, and even some gems.
0:50
Here we see on the left side,
0:53
that is all of the different files
that would be in this package.
0:54
And right now these are just
documentation links.
0:58
Here is where documentation gets good.
1:03
On the left side,
1:06
we have all of the different
classes that are part of Ruby Core.
1:07
Some of these are going to look
very familiar, like Array.
1:12
I'm gonna go ahead and click on this here
and we can see the Array documentation.
1:16
Once we are inside of
the Array documentation,
1:22
we get a list of methods all
the way down on the left side here.
1:26
This is going to be the different instance
methods that are supported by Arrays.
1:30
On the right side of the documentation,
there will be an introduction.
1:37
This isn't the same for every single
class and module in Ruby Core however,
1:41
there could be some nice examples
in this part of the documentation.
1:47
So we some examples of using an Array and
what can be inside of an Array.
1:52
Sometimes the documentation will give you
little hints about how to use a class or
1:57
module, and here is an example of that.
2:03
If we wanna create an Array
with separate objects,
2:08
a block can be passed in
to the Array instead.
2:11
Now, if I hit the Back button,
you can see there are more classes and
2:16
modules that you might be familiar with.
2:20
For example, Strings as part of Ruby Core.
2:23
On the right side of the documentation
2:28
are all of the different methods
that are found in Ruby Core.
2:31
These will have parenthesis on the ride
side that shows you what class or
2:37
module they come from.
2:42
And, if we want to,
we can filter these classes and methods.
2:45
For example,
if we wanted to see what classes and
2:50
modules contained the word Object,
we could do that.
2:53
The methods can be interesting, too.
2:57
If we want to filter the methods
to see what's supported, for
2:59
example the to_s method which
converts something to a String.
3:03
We can see all of these different classes
and modules support the to_s method.
3:07
Also to_i,
to convert something to an integer.
3:15
To_f for floating point.
3:19
To_a for Array and to_h for Hatch.
3:23
It's good to be familiar with
the different classes and
3:30
modules that are part of Ruby Core.
3:33
Go ahead and
3:37
take a look at all of the different ones
here on the left side of the screen.
3:38
Try looking around at the Ruby Core
classes on your own now using Workspaces.
3:43
You need to sign up for Treehouse in order to download course files.
Sign up