<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:series="http://unfoldingneurons.com/"
	>

<channel>
	<title>Man With Code &#187; programming</title>
	<atom:link href="http://manwithcode.com/tag/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://manwithcode.com</link>
	<description>Teaching You, One Tutorial at a Time</description>
	<lastBuildDate>Tue, 22 Feb 2011 23:40:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Programming With Ruby Episode 17, Getting Advanced</title>
		<link>http://manwithcode.com/222/programming-with-ruby-episode-17-getting-advanced/</link>
		<comments>http://manwithcode.com/222/programming-with-ruby-episode-17-getting-advanced/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 08:56:27 +0000</pubDate>
		<dc:creator>Tyler</dc:creator>
				<category><![CDATA[Ruby Programming]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[advanced]]></category>
		<category><![CDATA[bindings]]></category>
		<category><![CDATA[eval]]></category>
		<category><![CDATA[external]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[symbols]]></category>

		<guid isPermaLink="false">http://manwithcode.com/?p=222</guid>
		<description><![CDATA[Covered In This Episode: Symbols eval Bindings Running Other Programs Safe Levels Transcript: Hello Everybody and welcome to Programming With Ruby Episode 17, Getting Advanced. I&#8217;m Tyler, and this video is brought to you by manwithcode.com. By now, you know a large amount about Ruby, so in this episode we will be going over some [...]]]></description>
			<content:encoded><![CDATA[<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/0dnHp7Yhbuo&amp;hl=en&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/0dnHp7Yhbuo&amp;hl=en&amp;fs=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><strong>Covered In This Episode:</strong></p>
<ul>
<li>Symbols</li>
<li>eval</li>
<li>Bindings</li>
<li>Running Other Programs</li>
<li>Safe Levels</li>
</ul>
<p><strong>Transcript:</strong></p>
<p>Hello Everybody and welcome to Programming With Ruby Episode 17,<br />
Getting Advanced. I&#8217;m Tyler, and this video is brought to you by<br />
manwithcode.com.</p>
<p>By now, you know a large amount about Ruby, so in this episode we will<br />
be going over some advanced features that Ruby has.</p>
<p>More specifically I will be teaching you what Symbols are, and when to<br />
use them. I will be showing you how to use eval, and how to use<br />
bindings with eval. You will learn how to run other programs from<br />
Ruby. Finally I will show you what safe levels are.</p>
<p>Lets get started!</p>
<p><strong>Symbols</strong></p>
<p>Symbols are a type of variable that are very much like strings, but<br />
more lightweight. Symbols look like this:</p>
<pre class="brush: ruby; title: ; notranslate">
:variable
</pre>
<p>Symbols can&#8217;t be manipulated like strings can, which seems like a huge<br />
drawback, but they do have a couple benefits.</p>
<p>Each time you use a string, to say access a hash. Ruby creates an<br />
instance of that string. Where if you use a symbol, it is only ever<br />
instanced once. Meaning that the use of symbols will take up less<br />
memory than strings will, if you are, say accessing a hash many times.</p>
<p>Symbols are also slightly easier to type since the colon is on the<br />
home row on US keyboards.</p>
<p><strong>eval</strong></p>
<p>eval is a way of running Ruby code that is contained in a string. For<br />
example, lets say you have a string that looks like this:</p>
<pre class="brush: ruby; title: ; notranslate">
&quot;puts 'Hello World'&quot;
</pre>
<p>It is just a simple string, so it does nothing. But, if you use the<br />
method eval on that string it will execute the code inside. So this<br />
will print Hello World! on to the screen:</p>
<pre class="brush: ruby; title: ; notranslate">
eval &quot;puts 'Hello World!'&quot;
</pre>
<p>This isn&#8217;t always useful, but you can use it if you want your users to<br />
be able to enter Ruby code into your program.</p>
<p>You can also pass bindings to eval. So if we had this method</p>
<pre class="brush: ruby; title: ; notranslate">
def my_method my_binding
    eval &quot;puts x&quot;, my_binding
end

x = 5
my_method binding
</pre>
<p>This outputs:</p>
<pre class="brush: plain; title: ; notranslate">
5
</pre>
<p>Some of you may notice that the variable x isn&#8217;t defined in the method <code>my_method</code>. By using the binding method, we can make variable scopes portable!</p>
<p><strong>Running Other Programs</strong></p>
<p>There comes a time when you will want to be able to run a program from<br />
Ruby, maybe you want to automate something, or simply get the output<br />
from an external program.</p>
<p>There are a few ways of doing this.</p>
<p>The first is with the method exec, which runs an external programs,<br />
and quits the Ruby script at the same time:</p>
<pre class="brush: ruby; title: ; notranslate">
exec('ls') # dir on windows
# Program never gets here
</pre>
<p>There is also system, which does the same thing, but doesn&#8217;t quit the<br />
Ruby script, and returns true or false if the program was successful:</p>
<pre class="brush: ruby; title: ; notranslate">
system('ls') # dir on windows
# we do get this far
</pre>
<p>Finally we have the &#8220;back-tick&#8221; `. Which looks like a sideways single<br />
quote. On my keyboard it is above the tab key. You surround your<br />
command in the back-ticks, like you would for a sting. Unlike the other<br />
two methods of running a program, this method also returns the output<br />
of the program you run.</p>
<pre class="brush: ruby; title: ; notranslate">
variable = `ls`
</pre>
<p><strong>Safe Levels</strong></p>
<p>If you are running a Ruby interpreter online or in another environment<br />
where users can enter in and run Ruby code. They hold the ability to<br />
wreak havoc on your system.</p>
<p>The way to prevent this from happening is by using safe levels. Safe<br />
levels are a way of preventing the user from getting access to the<br />
file system, or changing any variables that the program has.</p>
<p>You set safe levels by setting the $SAFE variable. By default it is<br />
set to zero.</p>
<pre class="brush: ruby; title: ; notranslate">
$SAFE = 4
</pre>
<p>Ruby &#8220;taints&#8221; objects that could be dangerous.</p>
<p>There are five different safe levels.<br />
0 =&gt; The default, you can do anything<br />
1 =&gt; Can&#8217;t use environment variable, eval, load, require, and more.<br />
2 =&gt; Same as above and also can&#8217;t use files<br />
3 =&gt; All objects created are tainted, can&#8217;t be untainted<br />
4 =&gt; You can do almost nothing&#8230; Can&#8217;t modify the untainted, can&#8217;t<br />
use exit. Basically completely safe and sand-boxed.</p>
<p>That brings us to the end of the episode. If you liked these videos,<br />
please donate. It costs me in both money and time to make them.</p>
<p>If you have any questions, comments, or suggestions please don&#8217;t<br />
hesitate to leave a comment on this page or email me at<br />
tyler@manwithcode.com</p>
<p>Thanks for watching, goodbye!</p>
]]></content:encoded>
			<wfw:commentRss>http://manwithcode.com/222/programming-with-ruby-episode-17-getting-advanced/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<series:name><![CDATA[Ruby Programming]]></series:name>
	</item>
		<item>
		<title>Programming With Ruby Episode 16, Benchmarking</title>
		<link>http://manwithcode.com/216/programming-with-ruby-episode-16-benchmarking/</link>
		<comments>http://manwithcode.com/216/programming-with-ruby-episode-16-benchmarking/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 08:31:11 +0000</pubDate>
		<dc:creator>Tyler</dc:creator>
				<category><![CDATA[Ruby Programming]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[benchmarking]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[speed]]></category>

		<guid isPermaLink="false">http://manwithcode.com/?p=216</guid>
		<description><![CDATA[Covered In This Episode: What is benchmarking? Benchmarking Profiling Transcript: Hello Everybody and welcome to Programming With Ruby Episode 16, Benchmarking. I&#8217;m Tyler and this video is brought to you by manwithcode.com. In this episode I will tell you what benchmarking is. You will learn how to preform benchmarking tests on some of your code. [...]]]></description>
			<content:encoded><![CDATA[<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/dsa2RLZQoJY&amp;hl=en&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/dsa2RLZQoJY&amp;hl=en&amp;fs=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><strong>Covered In This Episode:</strong></p>
<ul>
<li>What is benchmarking?</li>
<li>Benchmarking</li>
<li>Profiling</li>
</ul>
<p><strong>Transcript:</strong></p>
<p>Hello Everybody and welcome to Programming With Ruby Episode 16,<br />
Benchmarking. I&#8217;m Tyler and this video is brought to you by<br />
manwithcode.com.</p>
<p>In this episode I will tell you what benchmarking is. You will learn<br />
how to preform benchmarking tests on some of your code. And after that<br />
you will learn how to preform the more exhaustive benchmarking process<br />
called profiling.</p>
<p>This should be a very quick and easy episode, so lets get started!</p>
<p><strong>What is benchmarking?</strong></p>
<p>Basically benchmarking is measuring how fast your code runs. Whether<br />
that means your code as a whole or only parts of it. This can be<br />
useful so you can optimize your code to run faster, in the places it<br />
is running the slowest. Benchmarking is also commonly used to compare<br />
two different programs in the category of speed, which can be a<br />
selling point for many products.</p>
<p><strong>Benchmarking</strong></p>
<p>To get access to benchmarking make sure you put:</p>
<pre class="brush: ruby; title: ; notranslate">
require 'benchmark'
</pre>
<p>in your code.</p>
<p>The most simple form of benchmarking is Benchmark.measure:</p>
<pre class="brush: ruby; title: ; notranslate">
a = Benchmark.measure do
    1_000_000.times do |i|
        x = i
    end
end

puts a #=&gt; 0.400000   0.140000   0.540000 (  0.537934)
</pre>
<p>The last number is the actual time it took to run the test.</p>
<p>There is also Benchmark.bm, which is similar, but adds headings and<br />
allows you to do multiple tests.</p>
<pre class="brush: ruby; title: ; notranslate">
Benchmark.bm do |bm|
    bm.report('Test 1:') do
        1_000_000.times do
            x = 1
        end
    end
    bm.report('Test 2:') do
        1_000.times do
            x = &quot;Moo...&quot;
        end
    end
end

# Example Output:
#          user     system      total        real
# Test 1:  0.430000   0.120000   0.550000 (  0.563787)
# Test 2:  0.000000   0.000000   0.000000 (  0.000775)
</pre>
<p>Then there is Benchmark.bmbm, which is exactly the same as bm, but<br />
preforms a benchmark twice.</p>
<pre class="brush: plain; title: ; notranslate">
Example Benchmark.bmbm Output:
Rehearsal -------------------------------------------
Test 1:   0.370000   0.110000   0.480000 (  0.484865)
Test 2:   0.000000   0.000000   0.000000 (  0.000529)
---------------------------------- total: 0.480000sec

user     system      total        real
Test 1:   0.390000   0.090000   0.480000 (  0.477402)
Test 2:   0.000000   0.000000   0.000000 (  0.000529)
</pre>
<p>And that is all there is to know about simple benchmarking, on to<br />
profiling.</p>
<p><strong>Profiling</strong></p>
<p>Profiling takes benchmarking to the extreme. It tells you how much time each part of your code is take, and all you have to do is put:</p>
<pre class="brush: ruby; title: ; notranslate">
require 'profile'
</pre>
<p>at the top of your program!</p>
<pre class="brush: ruby; title: ; notranslate">
require 'profile'

class MyMath
    # Don't worry about the math, just the profiling output
    # We repeat the code to make it use up more time
    def self.x_offset angle, distance
        1000.times { distance * Math.sin(angle * Math::PI/180) }
    end

    def self.y_offset angle, distance
        1000.times { distance * Math.cos(angle * Math::PI/180) * -1 }
    end
end

MyMath.x_offset(220, 50)
MyMath.y_offset(220, 50)
</pre>
<p>And from the profiling output, we can see what took the longest:</p>
<pre class="brush: plain; title: ; notranslate">
%   cumulative   self              self     total
time   seconds   seconds    calls  ms/call  ms/call  name
72.41     0.21      0.21        2   105.00   145.00  Integer#times
10.34     0.24      0.03     4000     0.01     0.01  Fixnum#*
6.90     0.26      0.02     1000     0.02     0.02  Math.cos
6.90     0.28      0.02     2000     0.01     0.01  Float#/
3.45     0.29      0.01     1000     0.01     0.01  Float#*
0.00     0.29      0.00        1     0.00   140.00  MyMath#y_offset
0.00     0.29      0.00        1     0.00   150.00  MyMath#x_offset
0.00     0.29      0.00        1     0.00     0.00  Class#inherited
0.00     0.29      0.00     1000     0.00     0.00  Math.sin
0.00     0.29      0.00        2     0.00     0.00  Kernel.singleton_method_added
0.00     0.29      0.00        1     0.00   290.00  #toplevel
</pre>
<p>And that is it for today&#8217;s episode!</p>
<p>Please do not forget to show your appreciation by donating.</p>
<p>If you have any thing to say about anything related to Man With Code<br />
or these videos, please leave a comment below, or email me at<br />
tyler@manwithcode.com</p>
<p>Thanks for watching, Bye!</p>
]]></content:encoded>
			<wfw:commentRss>http://manwithcode.com/216/programming-with-ruby-episode-16-benchmarking/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<series:name><![CDATA[Ruby Programming]]></series:name>
	</item>
		<item>
		<title>Programming With Ruby Episode 15, Error Handling</title>
		<link>http://manwithcode.com/211/programming-with-ruby-episode-15-error-handling/</link>
		<comments>http://manwithcode.com/211/programming-with-ruby-episode-15-error-handling/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 08:23:20 +0000</pubDate>
		<dc:creator>Tyler</dc:creator>
				<category><![CDATA[Ruby Programming]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[errors]]></category>
		<category><![CDATA[handling]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://manwithcode.com/?p=211</guid>
		<description><![CDATA[Covered in this Episode: What are errors What is error handling begin&#8230;end rescue ensure raise Transcript: Hello Everybody and welcome to Programming With Ruby Episode 15, Error Handling. I&#8217;m Tyler and this video is brought to you by manwithcode.com. In this episode you will learn what exactly errors are, and what error handling is. You [...]]]></description>
			<content:encoded><![CDATA[<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/97zxHTwEk6g&amp;hl=en&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/97zxHTwEk6g&amp;hl=en&amp;fs=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><strong>Covered in this Episode:</strong></p>
<ul>
<li>What are errors</li>
<li>What is error handling</li>
<li>begin&#8230;end</li>
<li>rescue</li>
<li>ensure</li>
<li>raise</li>
</ul>
<p><strong>Transcript:</strong></p>
<p>Hello Everybody and welcome to Programming With Ruby Episode 15, Error<br />
Handling. I&#8217;m Tyler and this video is brought to you by<br />
manwithcode.com.</p>
<p>In this episode you will learn what exactly errors are, and what error<br />
handling is. You will also be learning how to use the begin&#8230;end,<br />
rescue, and ensure keywords, as well as the raise method.</p>
<p>Lets get started!</p>
<p><strong>What are Errors?</strong></p>
<p>There are two types of problems with programs. #1 is bugs, and #2 is<br />
errors. You&#8217;ve most likely heard of both of these types of problems<br />
before. But what are they?</p>
<p>Bugs are more subtle problems, the program still runs and acts<br />
normally, but it may be outputting the wrong data, or messing<br />
something else up. It is completely up to the programmer to find these<br />
bugs.</p>
<p>Errors actually stop the program from running, or at least running all<br />
the way through. There are ways of handling most types of errors,<br />
which you will be learning about in this episode.</p>
<p><strong>What is error handling?</strong></p>
<p>It is possible to catch some types of errors, which when left alone,<br />
would otherwise result in your program crashing.</p>
<p>Error handling is the process of catching those errors, and usually<br />
doing something about them, like informing the user, or executing on a<br />
contingency plan.</p>
<p>There are many things that can create errors, such as trying to read<br />
from a file that doesn&#8217;t exist, a user entering bad data, trying to<br />
call a method that does not exist, and the list goes on.</p>
<p>Some errors you can combat by using methods like File.exists? to check<br />
if a file exists before trying to open it. But there are other cases<br />
where this is not an option, or where you prefer to handle the problem<br />
a different way. In this episode I will show you how.</p>
<p><strong>Real Code</strong></p>
<p>Error handling starts with the begin&#8230;end block which looks like this:</p>
<pre class="brush: ruby; title: ; notranslate">
begin
    # Code here
end
</pre>
<p>In that block is where you put the code that has the possibility of<br />
generating an error. That block in itself doesn&#8217;t do anything, to<br />
actually handle the errors, you need to use the rescue keyword.</p>
<pre class="brush: ruby; title: ; notranslate">
begin
    # Possibly error inducing code here
rescue
    # What to do if an error happens
end
</pre>
<p>What ever is between &#8220;rescue&#8221; and &#8220;end&#8221; will be executed if an error<br />
occurs. But what if you have the potential for multiple errors? Then<br />
you must use multiple rescues specifying the error the handle:</p>
<pre class="brush: ruby; title: ; notranslate">
begin
    # Possibly error inducing code
rescue ArgumentError
    # If ArgumentError is raised
rescue NoMethodError
    # If NoMethodError is raised
end
</pre>
<p>What if you don&#8217;t know the exact name of the error? Either create the<br />
error yourself and look at the output when the program crashes. Go to<br />
<a title="Ruby Documentation" href="http://ruby-doc.org">http://ruby-doc.org</a> and find all classes ending Error. Or consult<br />
<a title="List of Errors" href="http://www.zenspider.com/Languages/Ruby/QuickRef.html#34">http://www.zenspider.com/Languages/Ruby/QuickRef.html#34</a></p>
<p>Now lets say you want something to happen regardless of whether or not<br />
the code generates an error. Say maybe you have to close a file, or<br />
end your connection to a database. Then you would want to use ensure!</p>
<pre class="brush: ruby; title: ; notranslate">
begin
    # ...
rescue
    # ...
ensure
    # This gets executed no matter what
end
</pre>
<p>Now that you know how to handle errors, how do you go about raising<br />
errors of your own? With raise, of course!</p>
<pre class="brush: ruby; title: ; notranslate">
def mymethod data
    if data.is_malformed?
        raise ArgumentError
    end
end
</pre>
<p>Why would you want to do this? It can serve as a better reminder to<br />
you or other programmers using your code that what they were doing is<br />
wrong. This can help stop bugs.</p>
<p>This brings us to the end of the episode.</p>
<p>If you have any questions, comments, or suggestions about anything<br />
related to Man With Code or these video tutorials; Please leave a<br />
comment below, or email me at tyler@manwithcode.com</p>
<p>Do not forget to donate. A lot of time and hard work went into making<br />
these. If you liked these videos the best way to show your<br />
appreciation is by donating.</p>
<p>Thanks for watching, goodbye!</p>
]]></content:encoded>
			<wfw:commentRss>http://manwithcode.com/211/programming-with-ruby-episode-15-error-handling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<series:name><![CDATA[Ruby Programming]]></series:name>
	</item>
		<item>
		<title>Programming With Ruby Episode 13, Basic I/O</title>
		<link>http://manwithcode.com/197/programming-with-ruby-episode-13-basic-io/</link>
		<comments>http://manwithcode.com/197/programming-with-ruby-episode-13-basic-io/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 08:07:03 +0000</pubDate>
		<dc:creator>Tyler</dc:creator>
				<category><![CDATA[Ruby Programming]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[directories]]></category>
		<category><![CDATA[files]]></category>
		<category><![CDATA[input]]></category>
		<category><![CDATA[io]]></category>
		<category><![CDATA[output]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://manwithcode.com/?p=197</guid>
		<description><![CDATA[Covered in this Episode: Defining I/O Files Directories Transcript: Hello Everybody and welcome to Programming With Ruby Episode 13, Basic input output. As always, I&#8217;m Tyler and this video is brought to you by manwithcode.com In this episode I will be defining what exactly input/output is, You will also learn how to work with files [...]]]></description>
			<content:encoded><![CDATA[<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/x-ru_Hw7YNI&amp;hl=en&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/x-ru_Hw7YNI&amp;hl=en&amp;fs=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><strong>Covered in this Episode:</strong></p>
<ul>
<li>Defining I/O</li>
<li>Files</li>
<li>Directories</li>
</ul>
<p><strong>Transcript:</strong></p>
<p>Hello Everybody and welcome to Programming With Ruby Episode 13, Basic<br />
input output. As always, I&#8217;m Tyler and this video is brought to you by<br />
manwithcode.com</p>
<p>In this episode I will be defining what exactly input/output is, You<br />
will also learn how to work with files and directories in Ruby</p>
<p>Lets get started!</p>
<p><strong>Defining I/O</strong></p>
<p>So what exactly is I/O or input/output. Basically Input is any data that<br />
you receive from the user, and output is what data you give to the<br />
user, usually based on what input the user gave you.</p>
<p>In this episode you will be seeing I/O as working with files and<br />
directories. You have already worked with I/O previously when we<br />
talked about getting strings from the user (gets) and printing string<br />
to the screen (puts)</p>
<p><strong>Files</strong></p>
<p>There are a couple of ways to start working with files. The first is<br />
by using File.new:</p>
<pre class="brush: ruby; title: ; notranslate">
my_file = File.new('file', 'r')
my_file.close
</pre>
<p>File.new opens the file (the first parameter), for the specified mode<br />
(the second parameter)</p>
<p>The file name you use can be either just the relative file name<br />
(notes.txt) or the full path to the file (C:\Documents and<br />
Settings\Tyler\My Documents\notes.txt). Just remember that if you use<br />
only the file name, that file must be in the same folder your program<br />
is located in!</p>
<p>The mode defines how you are going to use the file you&#8217;ve opened. In<br />
the example &#8216;r&#8217; is used. Which stands for read, meaning we are only<br />
going to read from the file.</p>
<p>&#8216;w&#8217; is write meaning we are writing to the file specified, be careful<br />
when using write mode, as the whole file is cleared when it is opened.</p>
<p>&#8216;a&#8217; is append, which is similar to write, except instead of clearing<br />
the whole file, it appends all written data to the end.</p>
<p>All the different modes can have &#8216;+&#8217; at the end of them, which opens<br />
up both read and write functionality. (ex: &#8216;w+&#8217;)</p>
<p>Now you know how to open a file, how exactly do yo go about writing to<br />
it? By simply using puts and print, like you did when outputting data<br />
to the screen, except they output data to the file!</p>
<pre class="brush: ruby; title: ; notranslate">
my_file = File.new('example.txt', 'w')
my_file.puts &quot;Hello World!&quot;
my_file.close
</pre>
<p>If you want to read from a file you can use File.read:</p>
<pre class="brush: ruby; title: ; notranslate">
my_file = File.new('example.txt', 'r')
puts my_file.read
my_file.close
</pre>
<p>You can also pass in how many characters you want to read as a parameter.</p>
<p>If you would rather have the lines of a file in an array, you can use<br />
file.readlines.</p>
<p>If you are unsure a file exists you can simply use File.exists?:</p>
<pre class="brush: ruby; title: ; notranslate">
File.exists(&quot;notes.txt&quot;)
</pre>
<p>Now it is important to note that every time I am done using a file I<br />
call the .close method, why do I do this? Because if you don&#8217;t close<br />
your access on the file, it can become unusable by other<br />
programs. Also, your computers operating system might not write the<br />
changes you&#8217;ve made to the file, until your program has released its<br />
hold on it.</p>
<p>As an alternative to using file.close every single time, we can use<br />
File.open, instead of File.new. File.open lets us use the file in a<br />
code block, at the end of the code block, the file is closed<br />
automatically.</p>
<pre class="brush: ruby; title: ; notranslate">
File.open('hello.txt', 'w') do |file|
    file.puts &quot;Hello World!&quot;
end
</pre>
<p>There is a whole lot more you can do with files in Ruby to learn more<br />
go to http://ruby-doc.org/core-1.8.7/index.html and find the File and IO class</p>
<p><strong>Directories</strong></p>
<p>You can work with directories (also known as folders) in Ruby using<br />
Dir. You can create directories with Dir.mkdir:</p>
<pre class="brush: ruby; title: ; notranslate">
Dir.mkdir(&quot;Hello&quot;)
</pre>
<p>You can get an array of all the files and directories that are in the<br />
current directory with Dir.entries:</p>
<pre class="brush: ruby; title: ; notranslate">
Dir.entries('.')
</pre>
<p>Keep in mind that . is your current directory, and .. is the directory<br />
one level above the current one. Also, like files you can specify the<br />
relative path or the full path.</p>
<p>There is also another method similar to Dir.entries, Dir.foreach. They<br />
are essentially the same, except foreach allows you to iterate over<br />
each item in a code block.</p>
<pre class="brush: ruby; title: ; notranslate">
Dir.foreach('.') do |entry|
    puts entry
end
</pre>
<p>Like Files, there is a lot of material I couldn&#8217;t cover to learn more<br />
go to http://ruby-doc.org/core-1.8.7/index.html and find the Dir class</p>
<p>This brings us to the end of the episode.</p>
<p>If you like these videos please donate.</p>
<p>And if you have any Questions, Comments or Suggestions, you can leave<br />
a comment in the comment box below, or email me at<br />
tyler@manwithcode.com</p>
<p>Thank you very much for watching, goodbye.</p>
]]></content:encoded>
			<wfw:commentRss>http://manwithcode.com/197/programming-with-ruby-episode-13-basic-io/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<series:name><![CDATA[Ruby Programming]]></series:name>
	</item>
		<item>
		<title>Programming With Ruby Episode 9, Flow Control</title>
		<link>http://manwithcode.com/149/programming-with-ruby-episode-9-flow-control/</link>
		<comments>http://manwithcode.com/149/programming-with-ruby-episode-9-flow-control/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 10:24:19 +0000</pubDate>
		<dc:creator>Tyler</dc:creator>
				<category><![CDATA[Ruby Programming]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[blocks]]></category>
		<category><![CDATA[case]]></category>
		<category><![CDATA[control]]></category>
		<category><![CDATA[else]]></category>
		<category><![CDATA[flow]]></category>
		<category><![CDATA[if]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[until]]></category>
		<category><![CDATA[when]]></category>
		<category><![CDATA[while]]></category>

		<guid isPermaLink="false">http://manwithcode.com/?p=149</guid>
		<description><![CDATA[Part 1: Part 2: Covered in this episode: Code Blocks if, else, unless case, when while, until, for loops Transcript: Hello everybody and welcome to Programming With Ruby Episode 9, Flow Control. I&#8217;m Tyler and this video is brought to you by manwithcode.com So far all of the programs and code that I have shown [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Part 1:</strong><br />
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/6uMw60C7tyY&amp;hl=en&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/6uMw60C7tyY&amp;hl=en&amp;fs=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><strong>Part 2:</strong><br />
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/zpqByOutHVU&amp;hl=en&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/zpqByOutHVU&amp;hl=en&amp;fs=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><strong>Covered in this episode:</strong></p>
<ul>
<li>Code Blocks</li>
<li>if, else, unless</li>
<li>case, when</li>
<li>while, until, for loops</li>
</ul>
<p><strong>Transcript:</strong></p>
<p>Hello everybody and welcome to Programming With Ruby Episode 9, Flow<br />
Control. I&#8217;m Tyler and this video is brought to you by manwithcode.com</p>
<p>So far all of the programs and code that I have shown you has been<br />
completely linear. There has been no way to loop based on a condition<br />
or do something based on what the user inputs.</p>
<p>In this episode I will be showing you how to do all this, and I will<br />
also be explaining to you what a code block is, since I&#8217;ve been<br />
mentioning them in almost every episode previous to this.</p>
<p>This episode is REALLY LONG! Feel free to pause the video and think<br />
about what&#8217;s been said or try out code yourself.</p>
<p><strong>Code Blocks</strong></p>
<p>Throughout the previous videos, I&#8217;ve been telling you about code<br />
blocks, I&#8217;ve also been telling you I&#8217;ll teach you what they are in a<br />
later episode. That episode has finally come.</p>
<p>Code blocks look something like this:</p>
<pre class="brush: ruby; title: ; notranslate">
my_array.each do |item|
    puts item
end
</pre>
<p>or like this:</p>
<pre class="brush: ruby; title: ; notranslate">
my_array.each { |item| puts item }
</pre>
<p>Both of those actually do the same thing! The .each method takes a<br />
block as an argument. The block is what is between the do and end<br />
keywords, or the curly braces, depending on which format you use.</p>
<p>The item between the pipe characters (which is above the ENTER key) is<br />
the variable the .each method gives you (in this case the item in the<br />
array).</p>
<p>The rest of the code block is just normal Ruby code. Not so complicated, eh?</p>
<p>(Keep in mind that there are more metheds besides .each that take code blocks)</p>
<p><strong>If, Else, and Unless</strong></p>
<p>A basic if statement would look like this:</p>
<pre class="brush: ruby; title: ; notranslate">
x = 3
if x &lt; 5
    # Do something
end
</pre>
<p>The &#8220;x &lt; 5&#8243; is the condition that has to be true for the code to<br />
run. If that condition is true, the code between the &#8220;if&#8221; and &#8220;end&#8221;<br />
keywords is run.</p>
<p>There are many different conditional operators you can use:</p>
<pre class="brush: ruby; title: ; notranslate">
==
&lt;
&gt;
&lt;=
&gt;=
!=
</pre>
<p>Just be sure to keep in mind that the &#8220;is equal&#8221; operator uses two<br />
equal signs, not one.</p>
<p>If you would like code that is run when the condition is false:</p>
<pre class="brush: ruby; title: ; notranslate">
x = 3
if x &lt; 5
    # Do something if true
else
    # Do something if false
end
</pre>
<p>In a similar way you can execute code if the first condition is false<br />
but a second is true:</p>
<pre class="brush: ruby; title: ; notranslate">
x = 3
if x &lt; 5
    # Do something if true
elsif x == 3
    # Do something if the first is false and this is true
else
    # Do something in all are false
end
</pre>
<p>In a different way you can only execute the code if two conditions are true:</p>
<pre class="brush: ruby; title: ; notranslate">
x = 3
y = 2
if x == 3 and y == 2
    # Do something
end
</pre>
<p>You can also only execute code if one of any conditions are true:</p>
<pre class="brush: ruby; title: ; notranslate">
x = 3
y = 4
if x == 3 or y == 2
    # Do something
end
</pre>
<p>There is also the evil twin brother of if, unless:</p>
<pre class="brush: ruby; title: ; notranslate">
x = 3
unless x == 3
    # if x is 3, this code will not run
end
</pre>
<p>You can chain all of these together in almost any way you choose.</p>
<p><strong>Case, When</strong></p>
<p>Another way to evaluate conditions is using case, when:</p>
<pre class="brush: ruby; title: ; notranslate">
x = 3
case x
    when 1 then
        # do something
    when 3 then
        # do something
    else
        # do something if none are true
end
</pre>
<p>You can&#8217;t do many complex conditionals, but it can be nicer than a<br />
long chain of if, else&#8217;s</p>
<p><strong>while, until, and for loops</strong></p>
<p>Similarly to the above if statements, while, until, and for loops will<br />
execute code based on a condition, but they will do it multiple times.</p>
<p>while:</p>
<pre class="brush: ruby; title: ; notranslate">
x = 1
while x &lt; 5
    x += 1
    puts x
end
</pre>
<p>Similar to the relationship between if, and unless. while has an evil<br />
sister, until</p>
<pre class="brush: ruby; title: ; notranslate">
x = 1
until x &gt; 5
    x += 1
    puts x
end
</pre>
<p>There are also for loops, which allow you to iterate over something</p>
<pre class="brush: ruby; title: ; notranslate">
foods = [&quot;ham&quot;, &quot;eggs&quot;, &quot;cheese&quot;]
for food in foods
    puts food += &quot; is yummy!&quot;
end
</pre>
<p>There is also .each, for&#8217;s evil stepchild:</p>
<pre class="brush: ruby; title: ; notranslate">
foods = [&quot;ham&amp;&quot;, &quot;eggs&quot;, &quot;cheese&quot;]
foods.each do |food|
    puts food += &quot; is yummy!&quot;
end
</pre>
<p><strong>Concrete Example</strong></p>
<p>A menu system</p>
<pre class="brush: ruby; title: ; notranslate">
input = &quot;&quot;
until input == 'quit'
    puts &quot;
Menu
(1) Hi!
(2) Credits
(3 or quit) Exit
&quot;
    input = gets.chomp!
    case input
        when &quot;1&quot; then
            puts &quot;Hi!&quot;
        when &quot;2&quot; then
            puts &quot;Written By: Tyler&quot;
        when &quot;3&quot; then
            input = 'quit'
        else
            puts &quot;Invalid input&quot;
    end
end
</pre>
<p><em>Lets break it down.</em></p>
<p>First we set the input variable to an empty string (so the second line<br />
dosen&#8217;t give us an error)</p>
<p>Then we use an until loop that quits when input is equal to &#8216;quit&#8217;</p>
<p>Next we print the menu (which is unindented so it doesn&#8217;t print to the<br />
screen indented)</p>
<p>After that we get input from the user, use .chomp! to remove the<br />
newline character created from pressing ENTER, and put the input into<br />
the input variable</p>
<p>Then we have a case statement, when &#8220;1&#8243; we print &#8220;Hi!&#8221;, when &#8220;2&#8243; we<br />
print who it was created by, when &#8220;3&#8243; we quit, otherwise we print out<br />
&#8220;Invalid input&#8221; to tell the user they entered something wrong.</p>
<p>This brings us to the end of the video.</p>
<p>If you like these videos please donate, because I&#8217;m doing this all for free</p>
<p>If you have any questions, comments, or suggestions, you can leave a<br />
comment on this page. Or you can email me at tyler@manwithcode.com</p>
<p>I covered a lot of material in this episode and I urge you to watch it<br />
again, go to the original post and look at the code (link is in the<br />
description) and write some code yourself.</p>
<p>Thank you very much for watching, goodbye!</p>
]]></content:encoded>
			<wfw:commentRss>http://manwithcode.com/149/programming-with-ruby-episode-9-flow-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<series:name><![CDATA[Ruby Programming]]></series:name>
	</item>
		<item>
		<title>Programming With Ruby Episode 8, Hashes</title>
		<link>http://manwithcode.com/132/programming-with-ruby-episode-8-hashes/</link>
		<comments>http://manwithcode.com/132/programming-with-ruby-episode-8-hashes/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 06:33:11 +0000</pubDate>
		<dc:creator>Tyler</dc:creator>
				<category><![CDATA[Ruby Programming]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[hashes]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://manwithcode.com/?p=132</guid>
		<description><![CDATA[Covered In This Episode: What are Hashes? Hash Creation Hash Accessing Hash iteration Hash Methods Transcript: Hello Everybody and welcome to Programming With Ruby Episode 8, Hashes. I&#8217;m Tyler,and this video is brought to you by, manwithcode.com In this episode I will be telling you what hashes are, how you can create them, access them, [...]]]></description>
			<content:encoded><![CDATA[<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/LIrTu1UDATk&#038;hl=en&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/LIrTu1UDATk&#038;hl=en&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
<p><strong>Covered In This Episode:</strong></p>
<ul>
<li>What are Hashes?</li>
<li>Hash Creation</li>
<li>Hash Accessing</li>
<li>Hash iteration</li>
<li>Hash Methods</li>
</ul>
<p><strong>Transcript:</strong></p>
<p>Hello Everybody and welcome to Programming With Ruby Episode 8,<br />
Hashes. I&#8217;m Tyler,and this video is brought to you by, manwithcode.com</p>
<p>In this episode I will be telling you what hashes are, how you can<br />
create them, access them, and iterate over them. Finally at the end I<br />
will show you some useful methods that hashes have.</p>
<p><strong>What Are Hashes?</strong></p>
<p>Hashes are like arrays, which you learned about in the previous<br />
episode. Except that they have no order, and instead of being accessed<br />
by an index number, they are accessed by what is called a key (which<br />
can be anything). That key points to a value, which is the actual data<br />
inside the hash</p>
<p>Arrays are used for lists of data, where hashes are used to relate<br />
data. I may have a hash where the keys are my friend&#8217;s names, and the<br />
values are their birthdays.</p>
<p><strong>Hash Creation</strong></p>
<p>Similarly to how arrays are created with square brackets, hashes are<br />
created with curly brackets:</p>
<pre class="brush: ruby; title: ; notranslate">
my_hash = {}
</pre>
<p>Items are defined like this:</p>
<pre class="brush: ruby; title: ; notranslate">
birthdays = {&quot;Amy&quot; =&gt; &quot;May&quot;, &quot;Dakota&quot; =&gt; &quot;January&quot;}
</pre>
<p>Each key-value pair are separated by a comma, and their relation is<br />
defined with =&gt;</p>
<p><strong>Accessing Hashes</strong></p>
<p>You can access hashes in almost the same way you access arrays, except<br />
by using the key value, instead of an index number:</p>
<pre class="brush: ruby; title: ; notranslate">
brithdays[&quot;Amy&quot;] #=&gt; May
</pre>
<p>You can define new keys and values:</p>
<pre class="brush: ruby; title: ; notranslate">
birthdays[&quot;Zack&quot;] = &quot;April&quot;
</pre>
<p><strong>Iterating Over Hashes</strong></p>
<p>Hashes have an each method like arrays do:</p>
<pre class="brush: ruby; title: ; notranslate">
my_hash = {&quot;cat&quot; =&gt; &quot;hat&quot;, &quot;dog&quot; =&gt; &quot;log&quot;}
my_hash.each do |pair|
	puts &quot;Key: &quot; + pair[0]
	puts &quot;Value: &quot; + pair[1]
end
#=&gt; Key: cat
#=&gt; Value: hat
#=&gt; Key: dog
#=&gt; Value: log
</pre>
<p>They also have each_key and each_value which let you iterate over each<br />
key or value in a similar way.</p>
<p><strong>Useful Hash Methods</strong></p>
<p><em>delete(key)</em> deletes a key-value pair<br />
<em>empty?</em> True or False if the hash is empty<br />
<em>keys</em> returns the keys<br />
<em>values</em> returns the values<br />
<em>size</em> how many key-value pairs there are</p>
<p>That wraps it up for this episode!</p>
<p>Please donate, or I will stop making these videos. There should be a<br />
link to donate to the right of this video.</p>
<p>If you have any questions or comments leave a comment on this page or<br />
email me at tyler@manwithcode.com</p>
<p>Thanks for watching, goodbye!</p>
]]></content:encoded>
			<wfw:commentRss>http://manwithcode.com/132/programming-with-ruby-episode-8-hashes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<series:name><![CDATA[Ruby Programming]]></series:name>
	</item>
		<item>
		<title>Programming With Ruby Episode 7, Arrays</title>
		<link>http://manwithcode.com/119/programming-with-ruby-episode-7-arrays/</link>
		<comments>http://manwithcode.com/119/programming-with-ruby-episode-7-arrays/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 06:19:31 +0000</pubDate>
		<dc:creator>Tyler</dc:creator>
				<category><![CDATA[Ruby Programming]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[arrays]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://manwithcode.com/?p=119</guid>
		<description><![CDATA[Covered In This Episode: What Aarrays Are Array Creation Accessing Arrays Array Iteration Other Array Methods Transcript: Hello everybody and welcome to Programming With Ruby Episode 7, Arrays. I&#8217;m Tyler. And this video is brought to you by manwithcode.com In this episode I will be telling you what arrays are, how you can create an [...]]]></description>
			<content:encoded><![CDATA[<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/_jHM-3h-Bag&#038;hl=en&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/_jHM-3h-Bag&#038;hl=en&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
<p><strong>Covered In This Episode:</strong></p>
<ul>
<li>What Aarrays Are</li>
<li>Array Creation</li>
<li>Accessing Arrays</li>
<li>Array Iteration</li>
<li>Other Array Methods</li>
</ul>
<p><strong>Transcript:</strong></p>
<p>Hello everybody and welcome to Programming With Ruby Episode 7,<br />
Arrays. I&#8217;m Tyler. And this video is brought to you by manwithcode.com</p>
<p>In this episode I will be telling you what arrays are, how you can<br />
create an array in ruby. How to manipulate arrays by accessing them,<br />
iterating over them, and by showing you a few useful methods they<br />
have.</p>
<p>Lets get started!</p>
<p><strong>What are Arrays?</strong></p>
<p>Arrays are a type of variable. Think of an array as a list. This list<br />
can hold anything, names, numbers, objects, anything. Objects in the<br />
array have a number, depending on what place they are in the<br />
list.</p>
<p>Because computers start counting at 0, the first element in the<br />
array is 0, instead of one.</p>
<p><strong>Array Creation</strong></p>
<p>This is how a variable is defined in ruby:</p>
<pre class="brush: ruby; title: ; notranslate">
x = []
</pre>
<p>This is an empty array, if we wanted an array with something in it:</p>
<pre class="brush: ruby; title: ; notranslate">
todo_list = [&quot;Cut Grass&quot;, &quot;Buy Food&quot;, &quot;Fix Tom's Computer&quot;]
</pre>
<p>Each bracket represents the start and the end of the array,<br />
respectively. Each item in an array is separated by a comma.</p>
<p><strong>Accessing Arrays</strong></p>
<p>Now that you have created an array, how do you go about accessing each<br />
item?</p>
<p>I told you earlier that each item had a number, so to access the first<br />
item in the array you would do:</p>
<pre class="brush: ruby; title: ; notranslate">
todo_list[0] #=&gt; &quot;Cut Grass&quot;
</pre>
<p>You can also add items to an array in a similar way</p>
<pre class="brush: ruby; title: ; notranslate">
todo_list[3] = &quot;Go Skydiving&quot;
</pre>
<p>Another way to add items is to use +=, which you may recognize from<br />
previous tutorials</p>
<pre class="brush: ruby; title: ; notranslate">
todo_list += [&quot;Eat Sandwich&quot;]
</pre>
<p>Don&#8217;t forget that if you use += that the item your adding has to be<br />
between brackets</p>
<p>You can also use ranges to access elements in the array. ranges are<br />
used in a similar way that you normally access arrays, except ranges<br />
look like this:</p>
<pre class="brush: ruby; title: ; notranslate">
todo_list[0..2] #=&gt; [&quot;Cut Grass&quot;, &quot;Buy Food&quot;, &quot;Fix Tom's Computer&quot;]
</pre>
<p>The 0 is the start number and the 2 is the end number. you can also<br />
use -1, which is the end of the array:</p>
<pre class="brush: ruby; title: ; notranslate">
todo_list[3..-1] #=&gt; [&quot;Go Skydiving&quot;, &quot;Eat Sandwich&quot;]
</pre>
<p><strong>Array Iteration</strong></p>
<p>If you want to loop over each element of an array you use the each<br />
method:</p>
<pre class="brush: ruby; title: ; notranslate">
numbers = [1, 2, 3, 4]
numbers.each do |number|
puts number * 2
end
#=&gt; 2 4 6 8
</pre>
<p>You can do the same thing, but turn the output into an array with the<br />
collect method:</p>
<pre class="brush: ruby; title: ; notranslate">
numbers = [1, 2, 3, 4]
numbers.each do |number|
number * 2
end
#=&gt; [2,4,6,8]
</pre>
<p><strong>Other Array Methods</strong></p>
<p>Now I&#8217;m going to show you some useful methods arrays have!</p>
<p><em>empty?</em> tells you if an array is empty<br />
<em>sort</em> sorts the array (alphabetically)<br />
<em>reverse</em> reverses the array<br />
<em>delete</em> deletes a specified item from the array<br />
<em>delete_at</em> deletes whatever is at that index in the array<br />
<em>find</em> finds an item with the specified value<br />
<em>inspect</em> returns the way an array looks in code, instead of its values, this is useful for puts my_array.inspect<br />
<em>length</em> how long the array is</p>
<p>That&#8217;s it for today&#8217;s episode</p>
<p>Please don&#8217;t forget to donate, the link should be to the right of this video</p>
<p>If you have any questions or comments, leave a comment on this page or<br />
email me at tyler@manwithcode.com</p>
<p>Thanks for watching, bye!</p>
]]></content:encoded>
			<wfw:commentRss>http://manwithcode.com/119/programming-with-ruby-episode-7-arrays/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<series:name><![CDATA[Ruby Programming]]></series:name>
	</item>
		<item>
		<title>Programming With Ruby Episode 6, Strings</title>
		<link>http://manwithcode.com/101/programming-with-ruby-episode-6-strings/</link>
		<comments>http://manwithcode.com/101/programming-with-ruby-episode-6-strings/#comments</comments>
		<pubDate>Thu, 21 May 2009 09:17:42 +0000</pubDate>
		<dc:creator>Tyler</dc:creator>
				<category><![CDATA[Ruby Programming]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[strings]]></category>

		<guid isPermaLink="false">http://manwithcode.com/?p=101</guid>
		<description><![CDATA[Covered in this episode: String Literals String Expressions String Methods Regular Expressions Getting User Input (gets) Transcript: Hello Everyone and Welcome to Programming With Ruby Episode 6, Strings. I&#8217;m Tyler, your presenter. This is brought to you by manwithcode.com In this episode I will be telling you what string literals are. I will show you [...]]]></description>
			<content:encoded><![CDATA[<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/1ot2Wlsgsog&amp;hl=en&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/1ot2Wlsgsog&amp;hl=en&amp;fs=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><strong>Covered in this episode:</strong></p>
<ul>
<li>String Literals</li>
<li>String Expressions</li>
<li>String Methods</li>
<li>Regular Expressions</li>
<li>Getting User Input (gets)<strong> </strong><strong></strong></li>
</ul>
<p><strong>Transcript:</strong></p>
<p>Hello Everyone and Welcome to Programming With Ruby Episode 6,<br />
Strings. I&#8217;m Tyler, your presenter. This is brought to you by<br />
manwithcode.com</p>
<p>In this episode I will be telling you what string literals are. I will<br />
show you expressions you can use with strings, which are similar but<br />
still different than expressions with numbers. I will show you useful<br />
methods strings have. I will show you how to use regular<br />
expressions. Finally I will teach you how to get input from the<br />
user.</p>
<p>On to the Code!</p>
<p><strong>String Literals</strong></p>
<p>According to wikipedia, string literals are the representation of a<br />
string value within the source code of a computer program. For<br />
example:</p>
<pre class="brush: ruby; title: ; notranslate">
puts &quot;Hello World&quot; # Hello World is the string literal
</pre>
<p><strong>String Expressons</strong></p>
<p>The only string expressions are the plus and multiplication sign. The<br />
plus sign connects strings together, the multiplication sign repeats a<br />
string a certain number of times.<br />
Let me show you how it works:</p>
<pre class="brush: ruby; title: ; notranslate">
&quot;Hello &quot; + &quot;World!&quot; #=&gt; &quot;Hello World!&quot;
&quot;Hello &quot; * 3 #=&gt; &quot;Hello Hello Hello&quot;
</pre>
<p><strong>String Methods</strong></p>
<p>Here are some useful String methods:<br />
<em>empty?</em> tells you if you are dealing with an empty string<br />
<em>length</em> tells you how long a string is<br />
<em>each_char</em> lets you iterate over each character<br />
<em>capitalize</em> capitalizes the first character<br />
<em>upcase</em> makes all characters upper case<br />
<em>downcase</em> makes all characters lower case</p>
<p><strong>Regular Expressions</strong></p>
<p>Regular expressions are a way to match elements in other strings. It<br />
is easier to show you than to describe to you, so here we go!</p>
<p>The simplest is substitution:</p>
<pre class="brush: ruby; title: ; notranslate">
&quot;Hello World&quot;.sub(&quot;Hello&quot;, &quot;Goodbye&quot;)
#=&gt; &quot;Goodbye World&quot;
</pre>
<p>But if you have more than one hello:</p>
<pre class="brush: ruby; title: ; notranslate">
&quot;Hello Hello Hello&quot;.sub(&quot;Hello&quot;, &quot;Goodbye&quot;)
#=&gt; &quot;Goodbye Hello Hello&quot;
</pre>
<p>This happens because the sub method only replaces the first occurrence<br />
of &#8220;Hello&#8221;. The gsub method fixes this:</p>
<pre class="brush: ruby; title: ; notranslate">
&quot;Hello Hello Hello&quot;.gsub(&quot;Hello&quot;, &quot;Goodbye&quot;)
#=&gt; &quot;Goodbye Goodbye Goodbye&quot;
</pre>
<p>What if you want to manipulate parts of a string using regular<br />
expressions. The scan method is what you want!</p>
<pre class="brush: ruby; title: ; notranslate">
# /n means new line
&quot;Who are you&quot;.scan(/../) { |x| puts x }
#=&gt; Wh\no \nar\ne \nyo
# With no whitespace:
&quot;Who are you&quot;.scan(/\w\w/) { |x| puts x }
#=&gt; Wh/nar/nyo
</pre>
<p>Regular Expressions are a vast topic that I can&#8217;t completely cover<br />
here, so do a Google search to find out more.</p>
<p><strong>Getting User Input</strong></p>
<p>You can get user input with the &#8220;gets&#8221; method:</p>
<pre class="brush: ruby; title: ; notranslate">
a = gets
# The user inputs: I like pie
puts a #=&gt; &quot;I like pie&quot;
</pre>
<p>That wraps it up for todays episode.</p>
<p>Don&#8217;t forget to donate, the link is to the right of this video</p>
<p>If you have any questions or comments, leave a comment on this page or<br />
email me at tyler@manwithcode.com</p>
<p>Bye!</p>
]]></content:encoded>
			<wfw:commentRss>http://manwithcode.com/101/programming-with-ruby-episode-6-strings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<series:name><![CDATA[Ruby Programming]]></series:name>
	</item>
		<item>
		<title>Programming With Ruby Episode 5, Numbers</title>
		<link>http://manwithcode.com/93/programming-with-ruby-episode-5-numbers/</link>
		<comments>http://manwithcode.com/93/programming-with-ruby-episode-5-numbers/#comments</comments>
		<pubDate>Fri, 24 Apr 2009 07:42:41 +0000</pubDate>
		<dc:creator>Tyler</dc:creator>
				<category><![CDATA[Ruby Programming]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[numbers]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://manwithcode.com/?p=93</guid>
		<description><![CDATA[Covered in This Episode Numbers Expressions Types of Numbers Constants (New type of variable!) Doing something a number of times Transcript Hello Everyone and Welcome to Programming With Ruby Episode 5, Numbers. Its sitll presented by me, Tyler. And brought to you by manwithcode.com In this episode I will be talking about numbers in Ruby. [...]]]></description>
			<content:encoded><![CDATA[<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/qdTM9mp0EsQ&#038;hl=en&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/qdTM9mp0EsQ&#038;hl=en&#038;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object><br />
<strong>Covered in This Episode</strong></p>
<ul>
<li>Numbers</li>
<li>Expressions</li>
<li>Types of Numbers</li>
<li>Constants (New type of variable!)</li>
<li>Doing something a number of times</li>
</ul>
<p><strong>Transcript</strong></p>
<p>Hello Everyone and Welcome to Programming With Ruby Episode 5,<br />
Numbers. Its sitll presented by me, Tyler. And brought to you by<br />
manwithcode.com</p>
<p>In this episode I will be talking about numbers in Ruby. I will go<br />
over expressions, the different types of numbers, I will introduce a<br />
new variable type called a constant, and will show you how to repeat<br />
an action a certain number of times in Ruby.</p>
<p>Lets get started!</p>
<p>Pop open you Command prompt or Terminal and start Interactive Ruby. If<br />
you have forgotten, just enter &#8216;irb&#8217;.</p>
<p>First item is expressions.</p>
<pre class="brush: ruby; title: ; notranslate">
2 + 2 #=&gt; 4
2 - 2 #=&gt; 0
3 * 3 #=&gt; 9
6 / 3 #=&gt; 2
2 ** 5 #=&gt; 5
</pre>
<p>expressions with variables work in the same way</p>
<pre class="brush: ruby; title: ; notranslate">
x = 5
5 * x #=&gt; 25
x ** 4 #=&gt; 625
</pre>
<p>If you want to do math on a variable and set the value of the variable<br />
to the result use:</p>
<pre class="brush: ruby; title: ; notranslate">
x = 5
x *= 2 #=&gt; x = 10
x -= 4 #=&gt; x = 6
x /= 6 #=&gt; x = 1
</pre>
<p>In Ruby there are 3 different types of numbers. Fixnum, which are<br />
32-bit numbers. Floats, which are numbers with a value after the<br />
decimal point. Bignums which are numbers larger than 32-bits.</p>
<pre class="brush: ruby; title: ; notranslate">
5.class #=&gt; Fixnum
0.421.class #=&gt; Float
999999999999 #=&gt; Bignum
</pre>
<p>In Ruby it is possible to separate up larger numbers to improve<br />
readability in the code. Simply place in underscores</p>
<pre class="brush: ruby; title: ; notranslate">
1_000_000 #=&gt; 1000000
</pre>
<p>Lets say you are writing some code and you need to do something a<br />
certain number of times. Use this code:</p>
<pre class="brush: ruby; title: ; notranslate">
2.times do |x|
puts x
end
#=&gt; 0
#=&gt; 1
</pre>
<p>That wraps it up for this episode. If you have any questions or<br />
comments, leave a comment in the comment box below. Or email me at<br />
tyler@manwithcode.com</p>
<p>Don&#8217;t forget to donate. The button is to the right of this video.</p>
<p>Thanks for watching. Goodbye</p>
]]></content:encoded>
			<wfw:commentRss>http://manwithcode.com/93/programming-with-ruby-episode-5-numbers/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<series:name><![CDATA[Ruby Programming]]></series:name>
	</item>
		<item>
		<title>Programming With Ruby Episode 4, Main Ruby Concepts</title>
		<link>http://manwithcode.com/84/programming-with-ruby-episode-4-main-ruby-concepts/</link>
		<comments>http://manwithcode.com/84/programming-with-ruby-episode-4-main-ruby-concepts/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 08:54:51 +0000</pubDate>
		<dc:creator>Tyler</dc:creator>
				<category><![CDATA[Ruby Programming]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[classes]]></category>
		<category><![CDATA[concepts]]></category>
		<category><![CDATA[main]]></category>
		<category><![CDATA[methods]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[variables]]></category>

		<guid isPermaLink="false">http://manwithcode.com/?p=84</guid>
		<description><![CDATA[Covered In This Episode: Basic Variables Basic Methods Basic Classes Interactive Ruby (irb) Code: Transcript: Hello everybody and welcome to Programming With Ruby Episode 4, Main Ruby Concepts. Covered in this episode. We&#8217;ll be playing with interactive ruby (also called irb). I will teach you about variables, basic methods, and classes in Ruby. Lets get [...]]]></description>
			<content:encoded><![CDATA[<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/8W7MJrAzeWw&#038;hl=en&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/8W7MJrAzeWw&#038;hl=en&#038;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object><br />
<strong>Covered In This Episode:</strong></p>
<ul>
<li>Basic Variables</li>
<li>Basic Methods</li>
<li>Basic Classes</li>
<li>Interactive Ruby (irb)</li>
</ul>
<p><strong>Code:</strong></p>
<pre class="brush: ruby; title: ; notranslate">
# Define the class Greeter
class Greeter
	# Define the method hello
	# This method greets the
	# user
	def hello(name)
		puts &quot;Hello &quot; + name
	end # End of the method hello
end # End of the class Greeter

Greeter.new.hello(&quot;Tyler&quot;)
</pre>
<p><strong><br />
</strong></p>
<p><strong>Transcript:</strong></p>
<p>Hello everybody and welcome to Programming With Ruby Episode 4, Main<br />
Ruby Concepts.</p>
<p>Covered in this episode. We&#8217;ll be playing with interactive ruby (also</p>
<p>called irb). I will teach you about variables, basic methods, and</p>
<p>classes in Ruby. Lets get started!</p>
<p><strong>Basics Description</strong></p>
<p>Ruby is an object oriented programming language. object oriented<br />
languages use objects. Ruby goes beyond most other object oriented<br />
languages, because in Ruby, everything is an object. (I&#8217;ll show you<br />
exactly what that means in a few minutes)</p>
<p>Object oriented programming sort of models real life. Look around you,<br />
everything around you is an object. Your computer, your desk, books,<br />
the moon, and people are all objects.</p>
<p>In programming, all objects have properties called variables. These<br />
could be the color of the object, the weight, size, or any other kind<br />
of property.</p>
<p>Objects also have methods (which are sometimes called functions). A<br />
camera object would have a method to take pictures. A car would have a<br />
method to drive. A printer would have a method to print.</p>
<p>As well as making code easier to understand, you will also continue to<br />
appreciate other benefits of object oriented programming further on in<br />
your programming career.</p>
<p><strong>Example</strong></p>
<p>I have written a very basic Ruby program. This is about what most<br />
programs look like, just a lot simpler. Let&#8217;s break it down line by<br />
line.</p>
<p>Everything followed by a hash mark (#), is ignored by Ruby. These are<br />
called comments. In these comments you can describe what your code is<br />
doing, make notes to yourself, and other such things.</p>
<p>The first line says &#8220;class Greeter&#8221;. This line tells Ruby that we are<br />
now defining a class named &#8220;Greeter&#8221;. Please remember that all classes<br />
in Ruby start with a capital letter!</p>
<p>The next line says &#8220;def hello(name)&#8221;. This line means we are defining<br />
a function (def), named &#8220;hello&#8221;, that takes the parameter &#8220;name&#8221;.</p>
<p>The following line is a little trickier. &#8216;puts &#8220;Hello &#8221; +<br />
name&#8217;. &#8220;puts&#8221; means &#8220;put string&#8221;. our string is &#8220;Hello &#8221; + name. Now<br />
you&#8217;re probably wondering what the &#8220;+ name&#8221; is for. We&#8217;re aren&#8217;t doing<br />
math on strings, but we are connecting the variable &#8220;name&#8221; to our other<br />
string &#8220;Hello &#8220;.</p>
<p>The next two lines have the keyword &#8220;end&#8221;. The first end means we are<br />
done defining the function &#8220;hello&#8221;. The second &#8220;end&#8221; means we are done<br />
defining the class &#8220;Greeter&#8221;.</p>
<p>Below where the class &#8220;Greeter&#8221; ends we have the line &#8216;myname =<br />
&#8220;Tyler&#8221;&#8216;. This means are creating the variable myname and placing<br />
&#8220;Tyler&#8221; inside of it.</p>
<p>Next is, the line &#8220;person = Greeter.new&#8221;. This means we are<br />
instantiating a new greeter object named person.</p>
<p>Finally we have the line &#8220;person.hello(myname)&#8221;. This calls the<br />
person object&#8217;s method &#8220;hello&#8221; and passes the variable &#8220;myname&#8221; as an<br />
argument.</p>
<p>Now lets run the program. If you remember, to run a program you open<br />
Terminal or Command Prompt, change directories into where you saved<br />
your program and type &#8220;ruby programname.rb&#8221;. In my case I will type<br />
&#8220;ruby episode4.rb&#8221;.<br />
And there you have it, it says &#8220;Hello Tyler&#8221;</p>
<p>The code in this example will be available in the YouTube video<br />
description, and below this video on manwithcode.com</p>
<p><strong>Example 2</strong><br />
Back to the code. This code is actually a little longer<br />
than it has to be. I did this so things would hopefully make more<br />
sense. In reality we can change the last three lines to<br />
&#8216;Greeter.new.hello(&#8220;Tyler&#8221;)&#8217;</p>
<p>We can do this because in Ruby, everything is an expression. Here&#8217;s how<br />
it breaks down. &#8220;Greeter.new&#8221; creates a greeter object. &#8220;.hello&#8221; calls<br />
the method &#8220;hello&#8221; on that new object. And then we pass in the string<br />
&#8220;Tyler&#8221; as an parameter.</p>
<p>Ruby has many other tricks like this to make your code shorter. Some<br />
have disadvantages and others do not. One of the most important<br />
disadvantages can be clarity or readability. You want your code to be<br />
as easy to understand as possible.</p>
<p><strong>irb</strong><br />
Interactive Ruby (or irb for short). irb makes it very easy to<br />
quickly test out code, find out if/how something works, do basic math,<br />
and write throwaway code you will only use once.</p>
<p>To open irb, open up your Command Prompt or Terminal and enter<br />
irb. Alternatively, if you are on Windows, go into All Programs and<br />
under Ruby will be a program name fxri which is an equivalent to irb.</p>
<p>In irb you can do basic math:</p>
<pre class="brush: ruby; title: ; notranslate">
2 + 2 #=&gt; 4
2**6 #=&gt; 64
2 * 5 #=&gt; 10
</pre>
<p>We can write any valid Ruby code. So we could write the greet method again.</p>
<pre class="brush: ruby; title: ; notranslate">
def greet(name)
    puts &quot;Hello &quot; + name
end
</pre>
<p>And then call it:</p>
<pre class="brush: ruby; title: ; notranslate">
greet(&quot;Tyler&quot;)
</pre>
<p>Remember earlier I said everything in Ruby was an object? I&#8217;ll show<br />
you what I mean. if you type in the name of an object and call the<br />
class method it will tell you its class.</p>
<pre class="brush: ruby; title: ; notranslate">
0.class #=&gt; Fixnum
&quot;Hello&quot;.class #=&gt;; String
String.class #=&gt; Class
</pre>
<p>I encourage you to play around with irb for a little while, try<br />
writing your own methods, and have some fun with it.</p>
<p><strong>End</strong><br />
This brings us to the end of this episode, I hope it helped<br />
you.  If you need any help, have questions or comments, leave a<br />
comment below or contact me at tyler@manwithcode.com</p>
<p>Don&#8217;t forget to donate! There is a donation link to the right of this<br />
video. On YouTube its in the description box. On my website, it is to<br />
the right of the video.</p>
<p>Thanks for watching! Bye!</p>
]]></content:encoded>
			<wfw:commentRss>http://manwithcode.com/84/programming-with-ruby-episode-4-main-ruby-concepts/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<series:name><![CDATA[Ruby Programming]]></series:name>
	</item>
		<item>
		<title>Programming With Ruby Episode 3, Getting Help/Tools</title>
		<link>http://manwithcode.com/74/programming-with-ruby-episode-3-getting-help-tools/</link>
		<comments>http://manwithcode.com/74/programming-with-ruby-episode-3-getting-help-tools/#comments</comments>
		<pubDate>Thu, 26 Mar 2009 09:21:07 +0000</pubDate>
		<dc:creator>Tyler</dc:creator>
				<category><![CDATA[Ruby Programming]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[help]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://manwithcode.com/?p=74</guid>
		<description><![CDATA[Covered in this episode: How to get help Google Ruby&#8217;s Documentation Forums/Mailing Lists Blogs on Ruby Text Editors Integrated Development Environments (IDEs) Links: Ruby-Lang: http://www.ruby-lang.org Ruby-Doc:  http://www.ruby-doc.org/ Forums: http://www.ruby-forum.com/ http://www.rubyforums.com/ Text Editors: Notepad++ http://notepad-plus.sourceforge.net/uk/site.htm SciTE http://www.scintilla.org/SciTE.html jEdit http://www.jedit.org/ Text Mate http://macromates.com/ IDEs Netbeans http://www.netbeans.org/ Aptana Rad Rails http://www.aptana.com/ FreeRIDE http://rubyforge.org/projects/freeride/ Geany http://www.geany.org/ More&#8230; http://rubyforge.org/softwaremap/trove_list.php?form_cat=65 Transcript [...]]]></description>
			<content:encoded><![CDATA[<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/xwzalx7OcA4&amp;hl=en&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/xwzalx7OcA4&amp;hl=en&amp;fs=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><strong>Covered in this episode:</strong></p>
<ul>
<li>How to get help</li>
<li>Google</li>
<li>Ruby&#8217;s Documentation</li>
<li>Forums/Mailing Lists</li>
<li>Blogs on Ruby</li>
<li>Text Editors</li>
<li>Integrated Development Environments (IDEs)</li>
</ul>
<p><strong>Links:</strong></p>
<p>Ruby-Lang: <a title="Ruby Lang" href="http://www.ruby-lang.org" target="_blank">http://www.ruby-lang.org</a><br />
Ruby-Doc:  <a title="Ruby Documentation" href="http://www.ruby-doc.org/" target="_blank">http://www.ruby-doc.org/</a></p>
<p><strong>Forums:</strong></p>
<p><a title="Ruby Forum" href="http://www.ruby-forum.com/" target="_blank">http://www.ruby-forum.com/</a><br />
<a title="Ruby Forums" href="http://www.rubyforums.com/" target="_blank">http://www.rubyforums.com/</a></p>
<p><strong>Text Editors:</strong><br />
Notepad++ <a title="Notepad plus plus" href="http://notepad-plus.sourceforge.net/uk/site.htm" target="_blank">http://notepad-plus.sourceforge.net/uk/site.htm</a><br />
SciTE <a title="SciTE" href="http://www.scintilla.org/SciTE.html" target="_blank">http://www.scintilla.org/SciTE.html</a><br />
jEdit <a title="jedit" href="http://www.jedit.org/" target="_blank">http://www.jedit.org/</a><br />
Text Mate <a title="Text Mate" href="http://macromates.com/" target="_blank">http://macromates.com/</a></p>
<p><strong>IDEs</strong><br />
Netbeans <a title="Netbeans IDE" href="http://www.netbeans.org/" target="_blank">http://www.netbeans.org/</a><br />
Aptana Rad Rails <a title="Aptana Rad Rails" href="http://www.aptana.com/" target="_blank">http://www.aptana.com/</a><br />
FreeRIDE <a title="freeRIDE" href="http://rubyforge.org/projects/freeride/" target="_blank">http://rubyforge.org/projects/freeride/</a><br />
Geany <a title="Geany IDE" href="http://www.geany.org/" target="_blank">http://www.geany.org/</a><br />
More&#8230;<a title="More IDEs on Rubyforge" href="http://rubyforge.org/softwaremap/trove_list.php?form_cat=65" target="_blank"> http://rubyforge.org/softwaremap/trove_list.php?form_cat=65</a></p>
<p><strong>Transcript</strong></p>
<p>Hello Everybody! And Welcome to Programming with Ruby Episode 3, Getting Help<br />
and Tools. I&#8217;m your presenter, Tyler. This video is brought to you by<br />
manwithcode.com</p>
<p>Covered in this Episode.<br />
I&#8217;ll be going over how to get help.<br />
If you ever get stuck while using Ruby you&#8217;re first stop should be Google,<br />
to some this may sound obvious, but some people still don&#8217;t use Google.<br />
Your next stop would be Ruby&#8217;s Documentation.<br />
Then I will be showing you forums and mailing lists where you can ask for help<br />
or help others.<br />
Also I will be showing you some blogs by Ruby Developers.</p>
<p>On the tools side, I will be showing you some good Text Editors, and a few<br />
IDEs (or Integrated Development Environments).</p>
<p>Just as a side note, I will be showing many websites today, but don&#8217;t worry,<br />
all links are in the description</p>
<p>Lets Get Started!</p>
<p>Out first stop will be Google. Lets say I wanted to learn about Ruby Lambdas<br />
just type in &#8220;ruby lamdas&#8221; and you get a list of relavant web pages. I&#8217;ll<br />
pick the first link, and here is some information on how to use lambdas.</p>
<p>If Google can&#8217;t help you, lets look at the official Ruby Documentation.<br />
This is ruby-doc.org. It has some articles and tutorials on Ruby. But what<br />
we are interested in is the part that says &#8220;Core API&#8221; we are using the<br />
1.8 version of Ruby, so we will visit the 1.8.6 core link<br />
and here is the documentation for Ruby! lets say I wanted to look for lambdas<br />
again, I&#8217;ll hit CTRL-F for the browsers find funtion, and type in &#8220;lambda&#8221; and<br />
here is the information I want, I&#8217;ll click the link, and there is the<br />
documentation!</p>
<p>Okay lets say that a Google search and a look through the documentation doesn&#8217;t<br />
help you with your problem. What do you do? You ask a person, of course! This<br />
is where the forums come in.</p>
<p>There are two forums that I like, there is ruby-forum.com<br />
And rubyforums.com<br />
both of which you can post on and will hopefully get answers</p>
<p>For general tips and news about Ruby, you may be interested in some blogs about<br />
Ruby. To find some, lets go to ruby-lang.org<br />
click on the community link.<br />
scroll down, and click the &#8220;weblogs about ruby&#8221; link<br />
and here there are some blogs, and aggregators listed</p>
<p>So hopefully if you have a problem all these resources should be able to help<br />
you. Now we are going to move onto tools. First stop Text Editors.</p>
<p>There are a few good text editors available, so I will just highlight a few.<br />
If any of these look interesting, remember that all links are in the description.<br />
First is Windows only text editor notepad++, the editor I use on Windows<br />
Then is SciTE, a scintilla based editor<br />
Jedit is a popular text editor that is written in Java<br />
Text mate is a very popular text editor for the Macintosh that costs $55<br />
For Linux there are editors like gEdit and Kate which have some of the features<br />
of the editors mentioned above.</p>
<p>Even if you like your featureless plain text editor like notepad, features the<br />
previously mentioned editors have make writing code much easier, and I recommend<br />
you get one.</p>
<p>First we have netbeans, which is my IDE of choice. Even though it was originally<br />
for Java, it works very well with Ruby<br />
Next is Aptana rad rails, an IDE which many people like, but was too buggy on my<br />
computer, it is especially useful if you are using Ruby on Rails<br />
freeRIDE is a popular editor for ruby<br />
Geany is a GTK based editor for Linux that works with many different languages</p>
<p>These are all very good editors, but because you are currently learning I would<br />
just recommend a text editor for now, when you start developing larger projects<br />
an IDE can be very useful.</p>
<p>This brings us to the end of this episode, I hope it helped you.<br />
If you need any help, have questions or comments, leave a comment below or<br />
contact me at tyler@manwithcode.com</p>
<p>Hey! before you go, you may have realized that I am making these videos for free<br />
if they have helped you at all please donate. If you viewing this on Youtube there is a<br />
donation link to the right in the description box. If you are on my site there is<br />
a donation button to the right</p>
<p>Thanks for watching! Bye!</p>
]]></content:encoded>
			<wfw:commentRss>http://manwithcode.com/74/programming-with-ruby-episode-3-getting-help-tools/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<series:name><![CDATA[Ruby Programming]]></series:name>
	</item>
		<item>
		<title>Programming With Ruby Episode 1, Introduction</title>
		<link>http://manwithcode.com/31/programming-with-ruby-episode-1-introduction/</link>
		<comments>http://manwithcode.com/31/programming-with-ruby-episode-1-introduction/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 02:30:28 +0000</pubDate>
		<dc:creator>Tyler</dc:creator>
				<category><![CDATA[Ruby Programming]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[introduction]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://manwithcode.com/?p=31</guid>
		<description><![CDATA[Covered in this episode: What this series is about A Short History of programming languages What is Ruby (and who makes it) What is Ruby used for Who am I Why am I teaching this Transcript Hello everybody and welcome to Programming with Ruby Episode 1, Introduction What this series is about By the end [...]]]></description>
			<content:encoded><![CDATA[<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/p3jyESVlA2k&amp;hl=en&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/p3jyESVlA2k&amp;hl=en&amp;fs=1" allowscriptaccess="always" allowfullscreen="true"></embed></object><br />
<strong>Covered in this episode:</strong></p>
<ul>
<li>What this series is about</li>
<li>A Short History of programming languages</li>
<li>What is Ruby (and who makes it)</li>
<li>What is Ruby used for</li>
<li>Who am I</li>
<li>Why am I teaching this</li>
</ul>
<p><strong>Transcript</strong></p>
<p>Hello everybody and welcome to Programming with Ruby Episode 1, Introduction</p>
<p><strong>What this series is about </strong><br />
By the end of this series you should be able to effectively use the programming language, Ruby</p>
<p><strong>Short History of Programming Languages </strong><br />
when it all first started out, everything was just 1s and 0s, it was hard to use, and difficult to debug<br />
then it got a little better when assembly came along. You had words like MOV that translated into the corresponding 1s and 0s. compiled by and assembler<br />
then came COLBOL and FORTRAN<br />
then C, which was better, but still sucked<br />
then C++ which brought object orientation to the world<br />
then Python and Ruby. they are both object oriented and very easy to use.</p>
<p><strong>What is Ruby? </strong><br />
A programming language, that supports many different kinds of programming paradigms, and is fully object oriented<br />
Ruby was created by Yuukihiro &#8220;Matz&#8221; Matsumoto<br />
Matz designed Ruby to be natural, not simple. I think he achieved that.</p>
<p><strong>What is Ruby Used For?</strong><br />
Ruby is used a lot for Web Applications<br />
Computer Administration<br />
Task Automation<br />
Game Programming<br />
And almost anything else<br />
The only thing you might want to stay away from are things that are computationally expensive, like image processing.</p>
<p><strong>Who am I? </strong><br />
I am Tyler J Church<br />
I run the sites Man With Code (manwithcode.com) and ruby game dev (rubygamedev.wordpress.com)</p>
<p><strong>Why am I Teaching This?</strong><br />
It is the tutorial I never had. I was look for something like this when I started learning Ruby. I didn&#8217;t want to read a bunch, I wanted to watch videos, but nothing like that existed<br />
I think video is the best way to learn<br />
I want to give back to the community. That brought me Ruby, that helped me learn. Thank You!</p>
<p><strong>Questions or Comments </strong><br />
Leave a comment on this page<br />
or email me at tyler@manwithcode.com</p>
<p>Thanks for reading!</p>
]]></content:encoded>
			<wfw:commentRss>http://manwithcode.com/31/programming-with-ruby-episode-1-introduction/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<series:name><![CDATA[Ruby Programming]]></series:name>
	</item>
		<item>
		<title>Ruby Programming Series Announced</title>
		<link>http://manwithcode.com/23/ruby-programming-series-announced/</link>
		<comments>http://manwithcode.com/23/ruby-programming-series-announced/#comments</comments>
		<pubDate>Tue, 17 Mar 2009 23:43:53 +0000</pubDate>
		<dc:creator>Tyler</dc:creator>
				<category><![CDATA[Ruby Programming]]></category>
		<category><![CDATA[annoucement]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://manwithcode.com/?p=23</guid>
		<description><![CDATA[I am announcing that the first tutorial series will be on Ruby Programming! Outline for the Ruby Tutorial]]></description>
			<content:encoded><![CDATA[<p>I am announcing that the first tutorial series will be on Ruby Programming!</p>
<p><a title="Ruby Tutorial Outline" href="http://manwithcode.com/ruby-programming-tutorials/" target="_self">Outline for the Ruby Tutorial</a></p>
]]></content:encoded>
			<wfw:commentRss>http://manwithcode.com/23/ruby-programming-series-announced/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

