<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Class, Module and Test Example</title>
	<atom:link href="http://e168f09.plugh.org/2009/09/27/class-module-and-test-example/feed/" rel="self" type="application/rss+xml" />
	<link>http://e168f09.plugh.org/2009/09/27/class-module-and-test-example/</link>
	<description>Building Web-based Software with Ruby and Ruby on Rails</description>
	<lastBuildDate>Sat, 20 Feb 2010 02:50:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: peter</title>
		<link>http://e168f09.plugh.org/2009/09/27/class-module-and-test-example/comment-page-1/#comment-517</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Wed, 30 Sep 2009 01:47:27 +0000</pubDate>
		<guid isPermaLink="false">http://e168f09.plugh.org/?p=295#comment-517</guid>
		<description>&lt;a href=&quot;#comment-516&quot; rel=&quot;nofollow&quot;&gt;@john &lt;/a&gt; 

No I didnt.  I&#039;m using Ubuntu 9.04 and just went right down the list as it was on the site.  Installed ruby, rubygems from source, downloaded the actual .gem file for rails, used apt to get sqlite3, got the .gem for sqlite3-ruby

    * Ruby 1.9.1p243
    * RubyGems 1.3.5
    * Ruby on Rails 2.3.3 only
    * Sqlite 3.4.0 or later
    * The sqlite3-ruby gem, version 1.2.5

But that script does look pretty handy!

I did it the old fashioned way and installed ruby to /usr/local/ruby-1.9.1p243/ and then symlinked that to /usr/local/ruby/.  An old trick of mine, so if I did need to switch, I could install another version and just change the symlink.  

-peter</description>
		<content:encoded><![CDATA[<p><a href="#comment-516" rel="nofollow">@john </a> </p>
<p>No I didnt.  I'm using Ubuntu 9.04 and just went right down the list as it was on the site.  Installed ruby, rubygems from source, downloaded the actual .gem file for rails, used apt to get sqlite3, got the .gem for sqlite3-ruby</p>
<p>    * Ruby 1.9.1p243<br />
    * RubyGems 1.3.5<br />
    * Ruby on Rails 2.3.3 only<br />
    * Sqlite 3.4.0 or later<br />
    * The sqlite3-ruby gem, version 1.2.5</p>
<p>But that script does look pretty handy!</p>
<p>I did it the old fashioned way and installed ruby to /usr/local/ruby-1.9.1p243/ and then symlinked that to /usr/local/ruby/.  An old trick of mine, so if I did need to switch, I could install another version and just change the symlink.  </p>
<p>-peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: john</title>
		<link>http://e168f09.plugh.org/2009/09/27/class-module-and-test-example/comment-page-1/#comment-516</link>
		<dc:creator>john</dc:creator>
		<pubDate>Wed, 30 Sep 2009 01:31:03 +0000</pubDate>
		<guid isPermaLink="false">http://e168f09.plugh.org/?p=295#comment-516</guid>
		<description>&lt;a href=&quot;#comment-515&quot; rel=&quot;nofollow&quot;&gt;@peter &lt;/a&gt; 

Thanks. I sent an e-mail to all Linux students to warn them of this problem.

Just curious, Peter: Did you use the ruby_switcher.sh script for your setup . . . ?</description>
		<content:encoded><![CDATA[<p><a href="#comment-515" rel="nofollow">@peter </a> </p>
<p>Thanks. I sent an e-mail to all Linux students to warn them of this problem.</p>
<p>Just curious, Peter: Did you use the ruby_switcher.sh script for your setup . . . ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter</title>
		<link>http://e168f09.plugh.org/2009/09/27/class-module-and-test-example/comment-page-1/#comment-515</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Wed, 30 Sep 2009 01:15:28 +0000</pubDate>
		<guid isPermaLink="false">http://e168f09.plugh.org/?p=295#comment-515</guid>
		<description>All - 

Now I&#039;m starting to play with Rails, I had a slight issue with starting the WEBrick server on Ubuntu.  I am running with the original spec setup in Assignment 0.  I built it all from source, which went fine.  Except when I started the WEBrick it spit out some openssl lib errors.  A little googling solved the problem.  

Thought Id post a link or 2, in case anyone had the same error.  

I already had the openssl libssl-dev packages this guy said:
http://linuxnuggetz.blogspot.com/2009/06/ruby-on-rail-on-ubuntu.html

But it was this particular comment that solved my issue as well.  It involves rebuilding a piece of ruby from source, assuming thats how you installed it as well.
http://www.ruby-forum.com/topic/136893#609118

HTH

-peter</description>
		<content:encoded><![CDATA[<p>All - </p>
<p>Now I'm starting to play with Rails, I had a slight issue with starting the WEBrick server on Ubuntu.  I am running with the original spec setup in Assignment 0.  I built it all from source, which went fine.  Except when I started the WEBrick it spit out some openssl lib errors.  A little googling solved the problem.  </p>
<p>Thought Id post a link or 2, in case anyone had the same error.  </p>
<p>I already had the openssl libssl-dev packages this guy said:<br />
<a href="http://linuxnuggetz.blogspot.com/2009/06/ruby-on-rail-on-ubuntu.html" rel="nofollow">http://linuxnuggetz.blogspot.com/2009/06/ruby-on-rail-on-ubuntu.html</a></p>
<p>But it was this particular comment that solved my issue as well.  It involves rebuilding a piece of ruby from source, assuming thats how you installed it as well.<br />
<a href="http://www.ruby-forum.com/topic/136893#609118" rel="nofollow">http://www.ruby-forum.com/topic/136893#609118</a></p>
<p>HTH</p>
<p>-peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ron Newman</title>
		<link>http://e168f09.plugh.org/2009/09/27/class-module-and-test-example/comment-page-1/#comment-497</link>
		<dc:creator>Ron Newman</dc:creator>
		<pubDate>Mon, 28 Sep 2009 20:03:47 +0000</pubDate>
		<guid isPermaLink="false">http://e168f09.plugh.org/?p=295#comment-497</guid>
		<description>Much better now, thanks.</description>
		<content:encoded><![CDATA[<p>Much better now, thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan</title>
		<link>http://e168f09.plugh.org/2009/09/27/class-module-and-test-example/comment-page-1/#comment-494</link>
		<dc:creator>Jonathan</dc:creator>
		<pubDate>Mon, 28 Sep 2009 19:06:57 +0000</pubDate>
		<guid isPermaLink="false">http://e168f09.plugh.org/?p=295#comment-494</guid>
		<description>You&#039;re right. stringed.rb should be changed to the following:

&lt;code&gt;
def method_missing(m, *args)
    # catch all methods beginning with &quot;string_tuning_&quot;
    # this allows us to support an infinite number of strings, rather than simply 1..9
    if m.to_s[0..13] == &quot;string_tuning_&quot;
      # call string_tuning with everything that comes after string_tuning_
      # so string_tuning_10 calls string_tuning(10)
      string_tuning(m.to_s.delete(&#039;string_tuning_&#039;))
    else
      super
    end
  end
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>You're right. stringed.rb should be changed to the following:</p>
<p><code><br />
def method_missing(m, *args)<br />
    # catch all methods beginning with "string_tuning_"<br />
    # this allows us to support an infinite number of strings, rather than simply 1..9<br />
    if m.to_s[0..13] == "string_tuning_"<br />
      # call string_tuning with everything that comes after string_tuning_<br />
      # so string_tuning_10 calls string_tuning(10)<br />
      string_tuning(m.to_s.delete('string_tuning_'))<br />
    else<br />
      super<br />
    end<br />
  end<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ron Newman</title>
		<link>http://e168f09.plugh.org/2009/09/27/class-module-and-test-example/comment-page-1/#comment-492</link>
		<dc:creator>Ron Newman</dc:creator>
		<pubDate>Mon, 28 Sep 2009 18:34:07 +0000</pubDate>
		<guid isPermaLink="false">http://e168f09.plugh.org/?p=295#comment-492</guid>
		<description>[ruby  entities=&#039;1&#039;]
irb -r instrument.rb 
irb(main):001:0&gt; g = Guitar.new
=&gt; #&lt;Guitar:0x3df884 @tuning=[&quot;E&quot;, &quot;A&quot;, &quot;D&quot;, &quot;G&quot;, &quot;B&quot;, &quot;E&quot;], @tuning_hint=&quot;Eddie Ate Dynamite, Good Bye Eddie&quot;, @strings=[], @player=&quot;Jonathan Barket&quot;&gt;

irb(main):002:0&gt; g.tune_strings
=&gt; [&quot;E&quot;, &quot;B&quot;, &quot;G&quot;, &quot;D&quot;, &quot;A&quot;, &quot;E&quot;]

irb(main):003:0&gt; g.string_tuning_2
NoMethodError: undefined method `string_tuning_2&#039; for #&lt;Guitar:0x3df884&gt;
	from /Users/ronnewman/cs168/instrument/stringed.rb:49:in `method_missing&#039;
	from (irb):3
	from /Users/ronnewman/.ruby_versions/ruby-1.9.1-p243/bin/irb:12:in `&lt;main&gt;&#039;
[/ruby]

I think your Stringed#method_missing is always calling super, so no matter what argument it is called with, it&#039;s going to fail.</description>
		<content:encoded><![CDATA[<pre class="brush: ruby;">
irb -r instrument.rb
irb(main):001:0&gt; g = Guitar.new
=&gt; #&lt;Guitar:0x3df884 @tuning=[&quot;E&quot;, &quot;A&quot;, &quot;D&quot;, &quot;G&quot;, &quot;B&quot;, &quot;E&quot;], @tuning_hint=&quot;Eddie Ate Dynamite, Good Bye Eddie&quot;, @strings=[], @player=&quot;Jonathan Barket&quot;&gt;

irb(main):002:0&gt; g.tune_strings
=&gt; [&quot;E&quot;, &quot;B&quot;, &quot;G&quot;, &quot;D&quot;, &quot;A&quot;, &quot;E&quot;]

irb(main):003:0&gt; g.string_tuning_2
NoMethodError: undefined method `string_tuning_2' for #&lt;Guitar:0x3df884&gt;
	from /Users/ronnewman/cs168/instrument/stringed.rb:49:in `method_missing'
	from (irb):3
	from /Users/ronnewman/.ruby_versions/ruby-1.9.1-p243/bin/irb:12:in `&lt;main&gt;'
</pre>
<p>I think your Stringed#method_missing is always calling super, so no matter what argument it is called with, it's going to fail.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan</title>
		<link>http://e168f09.plugh.org/2009/09/27/class-module-and-test-example/comment-page-1/#comment-491</link>
		<dc:creator>Jonathan</dc:creator>
		<pubDate>Mon, 28 Sep 2009 18:19:39 +0000</pubDate>
		<guid isPermaLink="false">http://e168f09.plugh.org/?p=295#comment-491</guid>
		<description>The Sunday section is remote only. It&#039;s at 4:30 EST.

If you&#039;d like to attend, simply email me (jbarket [at] sleepunit.com) and I&#039;ll make sure to send you the URL. If there is a significant interest in coming to my section, I&#039;ll make a habit of posting the URL on the blog.

Since that code is the end result of what we played around with in section, method_missing never actually gets called. We ran through it, but I removed it. You can easily add code back to section.rb to play with it.

Essentially, you can call string_tuning_N where N is the string number you&#039;re looking for. method_missing will dynamically catch all of those and then call string_tuning(N). string_tuning returns the tuned value from strings[]. Since tuning is done from top to bottom (G, C, E, A) but strings are numbered bottom to top (4, 3, 2, 1), string_tuning reverses the array, and then subtracts one so that string 1 corresponds to array index 0.

We didn&#039;t get a chance to write any tests for method_missing, but that&#039;s a good idea for a place to test. Similar to how num_strings is tested to verify that it is returning the correct number of strings based on what self.tuning is set to, you could make calls to methods you expect to exist based on your tuning... string_tuning_1, string_tuning_2 and so on... or you could go beyond that and call something that _shouldn&#039;t_ exist (string_tuning_5 for the Ukulele class) and verify that you&#039;re correctly handling the case when they&#039;re stepped outside of the proper range.</description>
		<content:encoded><![CDATA[<p>The Sunday section is remote only. It's at 4:30 EST.</p>
<p>If you'd like to attend, simply email me (jbarket [at] sleepunit.com) and I'll make sure to send you the URL. If there is a significant interest in coming to my section, I'll make a habit of posting the URL on the blog.</p>
<p>Since that code is the end result of what we played around with in section, method_missing never actually gets called. We ran through it, but I removed it. You can easily add code back to section.rb to play with it.</p>
<p>Essentially, you can call string_tuning_N where N is the string number you're looking for. method_missing will dynamically catch all of those and then call string_tuning(N). string_tuning returns the tuned value from strings[]. Since tuning is done from top to bottom (G, C, E, A) but strings are numbered bottom to top (4, 3, 2, 1), string_tuning reverses the array, and then subtracts one so that string 1 corresponds to array index 0.</p>
<p>We didn't get a chance to write any tests for method_missing, but that's a good idea for a place to test. Similar to how num_strings is tested to verify that it is returning the correct number of strings based on what self.tuning is set to, you could make calls to methods you expect to exist based on your tuning... string_tuning_1, string_tuning_2 and so on... or you could go beyond that and call something that _shouldn't_ exist (string_tuning_5 for the Ukulele class) and verify that you're correctly handling the case when they're stepped outside of the proper range.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: john</title>
		<link>http://e168f09.plugh.org/2009/09/27/class-module-and-test-example/comment-page-1/#comment-490</link>
		<dc:creator>john</dc:creator>
		<pubDate>Mon, 28 Sep 2009 18:12:08 +0000</pubDate>
		<guid isPermaLink="false">http://e168f09.plugh.org/?p=295#comment-490</guid>
		<description>&lt;a href=&quot;#comment-489&quot; rel=&quot;nofollow&quot;&gt;@Ron Newman &lt;/a&gt; 

This is Jonathan&#039;s regular Sunday section -- not the one which I offered to hold, which interested no one.</description>
		<content:encoded><![CDATA[<p><a href="#comment-489" rel="nofollow">@Ron Newman </a> </p>
<p>This is Jonathan's regular Sunday section -- not the one which I offered to hold, which interested no one.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ron Newman</title>
		<link>http://e168f09.plugh.org/2009/09/27/class-module-and-test-example/comment-page-1/#comment-489</link>
		<dc:creator>Ron Newman</dc:creator>
		<pubDate>Mon, 28 Sep 2009 17:37:43 +0000</pubDate>
		<guid isPermaLink="false">http://e168f09.plugh.org/?p=295#comment-489</guid>
		<description>(Also, when and where is this Sunday section?   I thought it had been cancelled for lack of interest)</description>
		<content:encoded><![CDATA[<p>(Also, when and where is this Sunday section?   I thought it had been cancelled for lack of interest)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ron Newman</title>
		<link>http://e168f09.plugh.org/2009/09/27/class-module-and-test-example/comment-page-1/#comment-488</link>
		<dc:creator>Ron Newman</dc:creator>
		<pubDate>Mon, 28 Sep 2009 16:54:14 +0000</pubDate>
		<guid isPermaLink="false">http://e168f09.plugh.org/?p=295#comment-488</guid>
		<description>When running this application or tests, what code path will cause method_missing to be invoked?</description>
		<content:encoded><![CDATA[<p>When running this application or tests, what code path will cause method_missing to be invoked?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

