<?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/"
	>

<channel>
	<title>漂自己的移，让别人都撞墙去吧 &#187; Ruby</title>
	<atom:link href="http://www.gagahappy.com/tag/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gagahappy.com</link>
	<description>Life is what? Get busy living or get busy dying</description>
	<lastBuildDate>Tue, 07 Feb 2012 10:19:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>rails Rails::OrderedOptions</title>
		<link>http://www.gagahappy.com/rails-railsorderedoptions/</link>
		<comments>http://www.gagahappy.com/rails-railsorderedoptions/#comments</comments>
		<pubDate>Tue, 07 Feb 2012 10:19:21 +0000</pubDate>
		<dc:creator>moonfox</dc:creator>
				<category><![CDATA[程序开发]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.gagahappy.com/?p=3967</guid>
		<description><![CDATA[class Rails::OrderedOptions &#60; Array #:nodoc: def &#91;&#93;=&#40;key, value&#41; key = key.to_sym &#160; if pair = find_pair&#40;key&#41; pair.pop pair &#60;&#60; value else self &#60;&#60; &#91;key, value&#93; end end &#160; def &#91;&#93;&#40;key&#41; pair = find_pair&#40;key.to_sym&#41; pair ? pair.last : nil end &#160; def method_missing&#40;name, *args&#41; if name.to_s =~ /&#40;.*&#41;=$/ self&#91;$1.to_sym&#93; = args.first else self&#91;name&#93; end end &#160; [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#6666ff; font-weight:bold;">Rails::OrderedOptions</span> <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#CC0066; font-weight:bold;">Array</span> <span style="color:#008000; font-style:italic;">#:nodoc:</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span>=<span style="color:#006600; font-weight:bold;">&#40;</span>key, value<span style="color:#006600; font-weight:bold;">&#41;</span>
    key = key.<span style="color:#9900CC;">to_sym</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">if</span> pair = find_pair<span style="color:#006600; font-weight:bold;">&#40;</span>key<span style="color:#006600; font-weight:bold;">&#41;</span>
      pair.<span style="color:#9900CC;">pop</span>
      pair <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> value
    <span style="color:#9966CC; font-weight:bold;">else</span>
      <span style="color:#0000FF; font-weight:bold;">self</span> <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span>key, value<span style="color:#006600; font-weight:bold;">&#93;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#40;</span>key<span style="color:#006600; font-weight:bold;">&#41;</span>
    pair = find_pair<span style="color:#006600; font-weight:bold;">&#40;</span>key.<span style="color:#9900CC;">to_sym</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    pair ? pair.<span style="color:#9900CC;">last</span> : <span style="color:#0000FF; font-weight:bold;">nil</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> method_missing<span style="color:#006600; font-weight:bold;">&#40;</span>name, <span style="color:#006600; font-weight:bold;">*</span>args<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">if</span> name.<span style="color:#9900CC;">to_s</span> =~ <span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#40;</span>.<span style="color:#006600; font-weight:bold;">*</span><span style="color:#006600; font-weight:bold;">&#41;</span>=$<span style="color:#006600; font-weight:bold;">/</span>
      <span style="color:#0000FF; font-weight:bold;">self</span><span style="color:#006600; font-weight:bold;">&#91;</span>$1.<span style="color:#9900CC;">to_sym</span><span style="color:#006600; font-weight:bold;">&#93;</span> = args.<span style="color:#9900CC;">first</span>
    <span style="color:#9966CC; font-weight:bold;">else</span>
      <span style="color:#0000FF; font-weight:bold;">self</span><span style="color:#006600; font-weight:bold;">&#91;</span>name<span style="color:#006600; font-weight:bold;">&#93;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  private
    <span style="color:#9966CC; font-weight:bold;">def</span> find_pair<span style="color:#006600; font-weight:bold;">&#40;</span>key<span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">each</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>i<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#0000FF; font-weight:bold;">return</span> i <span style="color:#9966CC; font-weight:bold;">if</span> i.<span style="color:#9900CC;">first</span> == key <span style="color:#006600; font-weight:bold;">&#125;</span>
      <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#0000FF; font-weight:bold;">false</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>您可能感兴趣的文章<ol>
<li><a href='http://www.gagahappy.com/what-is-dup/' rel='bookmark' title='what is dup'>what is dup</a></li>
<li><a href='http://www.gagahappy.com/the-different-between-include-and-extend-in-ruby/' rel='bookmark' title='ruby 中 include 与 extend 区别'>ruby 中 include 与 extend 区别</a></li>
<li><a href='http://www.gagahappy.com/ruby-initialize-back-class-self/' rel='bookmark' title='ruby initialize 返回对象'>ruby initialize 返回对象</a></li>
<li><a href='http://www.gagahappy.com/ruby-install-rmagick/' rel='bookmark' title='ruby 安装 rmagick'>ruby 安装 rmagick</a></li>
<li><a href='http://www.gagahappy.com/rails-redirect_to/' rel='bookmark' title='rails redirect_to'>rails redirect_to</a></li>
<li><a href='http://www.gagahappy.com/try-reconstruction/' rel='bookmark' title='小试重构'>小试重构</a></li>
<li><a href='http://www.gagahappy.com/render-partial/' rel='bookmark' title='render partial'>render partial</a></li>
<li><a href='http://www.gagahappy.com/ri-rails-api/' rel='bookmark' title='使用ri查看Rails的API'>使用ri查看Rails的API</a></li>
<li><a href='http://www.gagahappy.com/belongs-to-primary-key/' rel='bookmark' title='belongs_to 选项中的:primary_key'>belongs_to 选项中的:primary_key</a></li>
<li><a href='http://www.gagahappy.com/add-gem-sources/' rel='bookmark' title='为gem添加源'>为gem添加源</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.gagahappy.com/rails-railsorderedoptions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ruby escape</title>
		<link>http://www.gagahappy.com/ruby-escape/</link>
		<comments>http://www.gagahappy.com/ruby-escape/#comments</comments>
		<pubDate>Mon, 06 Feb 2012 02:32:47 +0000</pubDate>
		<dc:creator>moonfox</dc:creator>
				<category><![CDATA[程序开发]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.gagahappy.com/?p=3955</guid>
		<description><![CDATA[require 'cgi' url = 'http://www.gagahappy.com/美食大下' url_escape = CGI::escape&#40;url&#41; url_unescape = CGI::unescape&#40;url_escape&#41; puts url_escape puts url_unescape 您可能感兴趣的文章 ruby p3p协议 Python赢得Tiobe 2010年度语言大奖 rails3.0怪异的数据库密码配置 rails项目开发环境一定要与服务器生产环境一致 ruby 安装 rmagick XPath image_tag validates_inclusion_of 使用ri查看Rails的API strftime函数将时间格式化]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'cgi'</span>
url = <span style="color:#996600;">'http://www.gagahappy.com/美食大下'</span>
url_escape = <span style="color:#CC00FF; font-weight:bold;">CGI</span>::escape<span style="color:#006600; font-weight:bold;">&#40;</span>url<span style="color:#006600; font-weight:bold;">&#41;</span>
url_unescape = <span style="color:#CC00FF; font-weight:bold;">CGI</span>::unescape<span style="color:#006600; font-weight:bold;">&#40;</span>url_escape<span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#CC0066; font-weight:bold;">puts</span> url_escape
<span style="color:#CC0066; font-weight:bold;">puts</span> url_unescape</pre></div></div>

<p>您可能感兴趣的文章<ol>
<li><a href='http://www.gagahappy.com/ruby-p3p-def/' rel='bookmark' title='ruby p3p协议'>ruby p3p协议</a></li>
<li><a href='http://www.gagahappy.com/python-tiobe-award/' rel='bookmark' title='Python赢得Tiobe 2010年度语言大奖'>Python赢得Tiobe 2010年度语言大奖</a></li>
<li><a href='http://www.gagahappy.com/rails3-passwd-must-to-be-string-format/' rel='bookmark' title='rails3.0怪异的数据库密码配置'>rails3.0怪异的数据库密码配置</a></li>
<li><a href='http://www.gagahappy.com/rails-dev-production/' rel='bookmark' title='rails项目开发环境一定要与服务器生产环境一致'>rails项目开发环境一定要与服务器生产环境一致</a></li>
<li><a href='http://www.gagahappy.com/ruby-install-rmagick/' rel='bookmark' title='ruby 安装 rmagick'>ruby 安装 rmagick</a></li>
<li><a href='http://www.gagahappy.com/xpath/' rel='bookmark' title='XPath'>XPath</a></li>
<li><a href='http://www.gagahappy.com/image_tag/' rel='bookmark' title='image_tag'>image_tag</a></li>
<li><a href='http://www.gagahappy.com/validates_inclusion_of/' rel='bookmark' title='validates_inclusion_of'>validates_inclusion_of</a></li>
<li><a href='http://www.gagahappy.com/ri-rails-api/' rel='bookmark' title='使用ri查看Rails的API'>使用ri查看Rails的API</a></li>
<li><a href='http://www.gagahappy.com/strftime/' rel='bookmark' title='strftime函数将时间格式化'>strftime函数将时间格式化</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.gagahappy.com/ruby-escape/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>如何理解ruby中的__FILE__？</title>
		<link>http://www.gagahappy.com/ruby-file-name-file/</link>
		<comments>http://www.gagahappy.com/ruby-file-name-file/#comments</comments>
		<pubDate>Sun, 05 Feb 2012 08:03:38 +0000</pubDate>
		<dc:creator>moonfox</dc:creator>
				<category><![CDATA[程序开发]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.gagahappy.com/?p=3963</guid>
		<description><![CDATA[require File.expand_path&#40;__FILE__ + '/../filename'&#41; 您可能感兴趣的文章 如何查看 ActiveRecord::Base.connection.executes 的执行结果？ what is dup ruby class_variable method Python赢得Tiobe 2010年度语言大奖 puts 返回值 ruby 安装 rmagick 小试重构 XPath render partial strftime函数将时间格式化]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">expand_path</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">__FILE__</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">'/../filename'</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>您可能感兴趣的文章<ol>
<li><a href='http://www.gagahappy.com/activerecordbase-connection-executes/' rel='bookmark' title='如何查看 ActiveRecord::Base.connection.executes 的执行结果？'>如何查看 ActiveRecord::Base.connection.executes 的执行结果？</a></li>
<li><a href='http://www.gagahappy.com/what-is-dup/' rel='bookmark' title='what is dup'>what is dup</a></li>
<li><a href='http://www.gagahappy.com/ruby-class_variable-method/' rel='bookmark' title='ruby class_variable method'>ruby class_variable method</a></li>
<li><a href='http://www.gagahappy.com/python-tiobe-award/' rel='bookmark' title='Python赢得Tiobe 2010年度语言大奖'>Python赢得Tiobe 2010年度语言大奖</a></li>
<li><a href='http://www.gagahappy.com/puts-back-value/' rel='bookmark' title='puts 返回值'>puts 返回值</a></li>
<li><a href='http://www.gagahappy.com/ruby-install-rmagick/' rel='bookmark' title='ruby 安装 rmagick'>ruby 安装 rmagick</a></li>
<li><a href='http://www.gagahappy.com/try-reconstruction/' rel='bookmark' title='小试重构'>小试重构</a></li>
<li><a href='http://www.gagahappy.com/xpath/' rel='bookmark' title='XPath'>XPath</a></li>
<li><a href='http://www.gagahappy.com/render-partial/' rel='bookmark' title='render partial'>render partial</a></li>
<li><a href='http://www.gagahappy.com/strftime/' rel='bookmark' title='strftime函数将时间格式化'>strftime函数将时间格式化</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.gagahappy.com/ruby-file-name-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>如何查看 ActiveRecord::Base.connection.executes 的执行结果？</title>
		<link>http://www.gagahappy.com/activerecordbase-connection-executes/</link>
		<comments>http://www.gagahappy.com/activerecordbase-connection-executes/#comments</comments>
		<pubDate>Sat, 04 Feb 2012 07:59:55 +0000</pubDate>
		<dc:creator>moonfox</dc:creator>
				<category><![CDATA[程序开发]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.gagahappy.com/?p=3959</guid>
		<description><![CDATA[拿mysql2这个gem来说：ActiveRecord::Base.connection.execute执行结果是Mysql2::Result的一个实例，这个类提供很多将执行结果解析出来的方法，例如：to_set、each、collect等，Mysql2::Result这些返回的一般都是数组，直接里面的元素的排序是按照数据库中字段的顺序排列的，按照数组的index直接取。 例如: results = ActiveRecord::Base.connection&#40;&#34;SELECT * FROM `users`&#34;&#41; results.each do &#124;result&#124; &#40;0..&#40;result.size -1&#41; do &#124;index&#124; puts result&#91;index&#93; end end 您可能感兴趣的文章 ruby p3p协议 ruby 中 include 与 extend 区别 rails3.0怪异的数据库密码配置 rails项目开发环境一定要与服务器生产环境一致 rails redirect_to image_tag render partial validates_inclusion_of 使用ri查看Rails的API 为gem添加源]]></description>
			<content:encoded><![CDATA[<p>拿mysql2这个gem来说：ActiveRecord::Base.connection.execute执行结果是Mysql2::Result的一个实例，这个类提供很多将执行结果解析出来的方法，例如：to_set、each、collect等，Mysql2::Result这些返回的一般都是数组，直接里面的元素的排序是按照数据库中字段的顺序排列的，按照数组的index直接取。 例如:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">results = <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>.<span style="color:#9900CC;">connection</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;SELECT * FROM `users`&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
results.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>result<span style="color:#006600; font-weight:bold;">|</span>
   <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">0</span>..<span style="color:#006600; font-weight:bold;">&#40;</span>result.<span style="color:#9900CC;">size</span> <span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>index<span style="color:#006600; font-weight:bold;">|</span>
      <span style="color:#CC0066; font-weight:bold;">puts</span> result<span style="color:#006600; font-weight:bold;">&#91;</span>index<span style="color:#006600; font-weight:bold;">&#93;</span>
   <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>您可能感兴趣的文章<ol>
<li><a href='http://www.gagahappy.com/ruby-p3p-def/' rel='bookmark' title='ruby p3p协议'>ruby p3p协议</a></li>
<li><a href='http://www.gagahappy.com/the-different-between-include-and-extend-in-ruby/' rel='bookmark' title='ruby 中 include 与 extend 区别'>ruby 中 include 与 extend 区别</a></li>
<li><a href='http://www.gagahappy.com/rails3-passwd-must-to-be-string-format/' rel='bookmark' title='rails3.0怪异的数据库密码配置'>rails3.0怪异的数据库密码配置</a></li>
<li><a href='http://www.gagahappy.com/rails-dev-production/' rel='bookmark' title='rails项目开发环境一定要与服务器生产环境一致'>rails项目开发环境一定要与服务器生产环境一致</a></li>
<li><a href='http://www.gagahappy.com/rails-redirect_to/' rel='bookmark' title='rails redirect_to'>rails redirect_to</a></li>
<li><a href='http://www.gagahappy.com/image_tag/' rel='bookmark' title='image_tag'>image_tag</a></li>
<li><a href='http://www.gagahappy.com/render-partial/' rel='bookmark' title='render partial'>render partial</a></li>
<li><a href='http://www.gagahappy.com/validates_inclusion_of/' rel='bookmark' title='validates_inclusion_of'>validates_inclusion_of</a></li>
<li><a href='http://www.gagahappy.com/ri-rails-api/' rel='bookmark' title='使用ri查看Rails的API'>使用ri查看Rails的API</a></li>
<li><a href='http://www.gagahappy.com/add-gem-sources/' rel='bookmark' title='为gem添加源'>为gem添加源</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.gagahappy.com/activerecordbase-connection-executes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ruby p3p协议</title>
		<link>http://www.gagahappy.com/ruby-p3p-def/</link>
		<comments>http://www.gagahappy.com/ruby-p3p-def/#comments</comments>
		<pubDate>Tue, 31 Jan 2012 02:54:36 +0000</pubDate>
		<dc:creator>moonfox</dc:creator>
				<category><![CDATA[程序开发]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.gagahappy.com/?p=3953</guid>
		<description><![CDATA[def p3p headers&#91;'P3P'&#93; = &#34;policyref=\&#34;/w3c/p3p.xml\&#34;, CP=\&#34;ALL DSP COR CURa ADMa DEVa TAIa OUR BUS IND UNI COM NAV INT\&#34;&#34; end 您可能感兴趣的文章 ruby 中 include 与 extend 区别 Python赢得Tiobe 2010年度语言大奖 ruby 安装 rmagick rails redirect_to XPath render partial validates_inclusion_of 使用ri查看Rails的API 为gem添加源 strftime函数将时间格式化]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">  <span style="color:#9966CC; font-weight:bold;">def</span> p3p
    headers<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'P3P'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">&quot;policyref=<span style="color:#000099;">\&quot;</span>/w3c/p3p.xml<span style="color:#000099;">\&quot;</span>, CP=<span style="color:#000099;">\&quot;</span>ALL DSP COR CURa ADMa DEVa TAIa OUR BUS IND UNI COM NAV INT<span style="color:#000099;">\&quot;</span>&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>您可能感兴趣的文章<ol>
<li><a href='http://www.gagahappy.com/the-different-between-include-and-extend-in-ruby/' rel='bookmark' title='ruby 中 include 与 extend 区别'>ruby 中 include 与 extend 区别</a></li>
<li><a href='http://www.gagahappy.com/python-tiobe-award/' rel='bookmark' title='Python赢得Tiobe 2010年度语言大奖'>Python赢得Tiobe 2010年度语言大奖</a></li>
<li><a href='http://www.gagahappy.com/ruby-install-rmagick/' rel='bookmark' title='ruby 安装 rmagick'>ruby 安装 rmagick</a></li>
<li><a href='http://www.gagahappy.com/rails-redirect_to/' rel='bookmark' title='rails redirect_to'>rails redirect_to</a></li>
<li><a href='http://www.gagahappy.com/xpath/' rel='bookmark' title='XPath'>XPath</a></li>
<li><a href='http://www.gagahappy.com/render-partial/' rel='bookmark' title='render partial'>render partial</a></li>
<li><a href='http://www.gagahappy.com/validates_inclusion_of/' rel='bookmark' title='validates_inclusion_of'>validates_inclusion_of</a></li>
<li><a href='http://www.gagahappy.com/ri-rails-api/' rel='bookmark' title='使用ri查看Rails的API'>使用ri查看Rails的API</a></li>
<li><a href='http://www.gagahappy.com/add-gem-sources/' rel='bookmark' title='为gem添加源'>为gem添加源</a></li>
<li><a href='http://www.gagahappy.com/strftime/' rel='bookmark' title='strftime函数将时间格式化'>strftime函数将时间格式化</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.gagahappy.com/ruby-p3p-def/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>what is dup</title>
		<link>http://www.gagahappy.com/what-is-dup/</link>
		<comments>http://www.gagahappy.com/what-is-dup/#comments</comments>
		<pubDate>Tue, 22 Nov 2011 08:35:59 +0000</pubDate>
		<dc:creator>moonfox</dc:creator>
				<category><![CDATA[程序开发]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.gagahappy.com/?p=3881</guid>
		<description><![CDATA[dup returns a copy (duplicate) of the object. In the above code, it is used to let you get back a shuffled copy of the Array, without shuffling the original. 您可能感兴趣的文章 ruby 中 include 与 extend 区别 为你的类混入Enumerable ruby initialize 返回对象 puts 返回值 ruby 安装 rmagick ruby 类测试 小试重构 升级gem提示缺少no such file to load zlib [...]]]></description>
			<content:encoded><![CDATA[<p>dup returns a copy (duplicate) of the object. In the above code, it is<br />
used to let you get back a shuffled copy of the Array, without<br />
shuffling the original.</p>
<p>您可能感兴趣的文章<ol>
<li><a href='http://www.gagahappy.com/the-different-between-include-and-extend-in-ruby/' rel='bookmark' title='ruby 中 include 与 extend 区别'>ruby 中 include 与 extend 区别</a></li>
<li><a href='http://www.gagahappy.com/mix-enumerable-into-your-class/' rel='bookmark' title='为你的类混入Enumerable'>为你的类混入Enumerable</a></li>
<li><a href='http://www.gagahappy.com/ruby-initialize-back-class-self/' rel='bookmark' title='ruby initialize 返回对象'>ruby initialize 返回对象</a></li>
<li><a href='http://www.gagahappy.com/puts-back-value/' rel='bookmark' title='puts 返回值'>puts 返回值</a></li>
<li><a href='http://www.gagahappy.com/ruby-install-rmagick/' rel='bookmark' title='ruby 安装 rmagick'>ruby 安装 rmagick</a></li>
<li><a href='http://www.gagahappy.com/ruby-%e7%b1%bb%e6%b5%8b%e8%af%95/' rel='bookmark' title='ruby 类测试'>ruby 类测试</a></li>
<li><a href='http://www.gagahappy.com/try-reconstruction/' rel='bookmark' title='小试重构'>小试重构</a></li>
<li><a href='http://www.gagahappy.com/update-gem-zlib/' rel='bookmark' title='升级gem提示缺少no such file to load zlib'>升级gem提示缺少no such file to load zlib</a></li>
<li><a href='http://www.gagahappy.com/belongs-to-primary-key/' rel='bookmark' title='belongs_to 选项中的:primary_key'>belongs_to 选项中的:primary_key</a></li>
<li><a href='http://www.gagahappy.com/add-gem-sources/' rel='bookmark' title='为gem添加源'>为gem添加源</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.gagahappy.com/what-is-dup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ruby class_variable method</title>
		<link>http://www.gagahappy.com/ruby-class_variable-method/</link>
		<comments>http://www.gagahappy.com/ruby-class_variable-method/#comments</comments>
		<pubDate>Fri, 23 Sep 2011 08:17:40 +0000</pubDate>
		<dc:creator>moonfox</dc:creator>
				<category><![CDATA[程序开发]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.gagahappy.com/?p=3839</guid>
		<description><![CDATA[class One @@var1 = 1 end class Two &#60; One @@var2 = 2 end One.class_variables #=&#62; [:@@var1] Two.class_variables #=&#62; [:@@var2] 您可能感兴趣的文章 ruby 中 include 与 extend 区别 为你的类混入Enumerable ruby initialize 返回对象 puts 返回值 ruby 安装 rmagick ruby 类测试 小试重构 升级gem提示缺少no such file to load zlib belongs_to 选项中的:primary_key 为gem添加源]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">   <span style="color:#9966CC; font-weight:bold;">class</span> One
     @@var1 = <span style="color:#006666;">1</span>
   <span style="color:#9966CC; font-weight:bold;">end</span>
   <span style="color:#9966CC; font-weight:bold;">class</span> Two <span style="color:#006600; font-weight:bold;">&lt;</span> One
     @@var2 = <span style="color:#006666;">2</span>
   <span style="color:#9966CC; font-weight:bold;">end</span>
   One.<span style="color:#9900CC;">class_variables</span>   <span style="color:#008000; font-style:italic;">#=&gt; [:@@var1]</span>
   Two.<span style="color:#9900CC;">class_variables</span>   <span style="color:#008000; font-style:italic;">#=&gt; [:@@var2]</span></pre></div></div>

<p>您可能感兴趣的文章<ol>
<li><a href='http://www.gagahappy.com/the-different-between-include-and-extend-in-ruby/' rel='bookmark' title='ruby 中 include 与 extend 区别'>ruby 中 include 与 extend 区别</a></li>
<li><a href='http://www.gagahappy.com/mix-enumerable-into-your-class/' rel='bookmark' title='为你的类混入Enumerable'>为你的类混入Enumerable</a></li>
<li><a href='http://www.gagahappy.com/ruby-initialize-back-class-self/' rel='bookmark' title='ruby initialize 返回对象'>ruby initialize 返回对象</a></li>
<li><a href='http://www.gagahappy.com/puts-back-value/' rel='bookmark' title='puts 返回值'>puts 返回值</a></li>
<li><a href='http://www.gagahappy.com/ruby-install-rmagick/' rel='bookmark' title='ruby 安装 rmagick'>ruby 安装 rmagick</a></li>
<li><a href='http://www.gagahappy.com/ruby-%e7%b1%bb%e6%b5%8b%e8%af%95/' rel='bookmark' title='ruby 类测试'>ruby 类测试</a></li>
<li><a href='http://www.gagahappy.com/try-reconstruction/' rel='bookmark' title='小试重构'>小试重构</a></li>
<li><a href='http://www.gagahappy.com/update-gem-zlib/' rel='bookmark' title='升级gem提示缺少no such file to load zlib'>升级gem提示缺少no such file to load zlib</a></li>
<li><a href='http://www.gagahappy.com/belongs-to-primary-key/' rel='bookmark' title='belongs_to 选项中的:primary_key'>belongs_to 选项中的:primary_key</a></li>
<li><a href='http://www.gagahappy.com/add-gem-sources/' rel='bookmark' title='为gem添加源'>为gem添加源</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.gagahappy.com/ruby-class_variable-method/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ruby 中 include 与 extend 区别</title>
		<link>http://www.gagahappy.com/the-different-between-include-and-extend-in-ruby/</link>
		<comments>http://www.gagahappy.com/the-different-between-include-and-extend-in-ruby/#comments</comments>
		<pubDate>Mon, 18 Jul 2011 15:36:38 +0000</pubDate>
		<dc:creator>moonfox</dc:creator>
				<category><![CDATA[程序开发]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.gagahappy.com/?p=3669</guid>
		<description><![CDATA[那么include和extend究竟有什么区别的？ 引用如下 include : mixes in specified module methods as instance methods in the target class extend : mixes in specified module methods as class methods in the target class 记得有看过的，被用到的时候居然忘记了。杯具啊！ module A def klass_method puts 'klass method' end &#160; def ins_method puts 'instance method' end &#160; end &#160; class B end &#160; B.class_eval do [...]]]></description>
			<content:encoded><![CDATA[<p>那么include和extend究竟有什么区别的？</p>
<p>引用如下</p>
<blockquote><p>include : mixes in specified module methods as instance methods in the target class<br />
extend : mixes in specified module methods as class methods in the target class</p></blockquote>
<p>记得有看过的，被用到的时候居然忘记了。杯具啊！<br />
<span id="more-3669"></span></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">module</span> A
    <span style="color:#9966CC; font-weight:bold;">def</span> klass_method
        <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">'klass method'</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">def</span> ins_method
        <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">'instance method'</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> B
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
B.<span style="color:#9900CC;">class_eval</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    <span style="color:#9966CC; font-weight:bold;">include</span> A
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
B.<span style="color:#9900CC;">new</span>.<span style="color:#9900CC;">ins_method</span> <span style="color:#008000; font-style:italic;"># 'should puts instance method'</span>
<span style="color:#008000; font-style:italic;">#B.klass_method # 'not define'</span>
&nbsp;
B.<span style="color:#9900CC;">class_eval</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    extend A
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
B.<span style="color:#9900CC;">klass_method</span> <span style="color:#008000; font-style:italic;"># 'klass method'</span>
B.<span style="color:#9900CC;">ins_method</span> <span style="color:#008000; font-style:italic;"># also as class method</span></pre></div></div>

<p>您可能感兴趣的文章<ol>
<li><a href='http://www.gagahappy.com/ruby-escape/' rel='bookmark' title='ruby escape'>ruby escape</a></li>
<li><a href='http://www.gagahappy.com/ruby-p3p-def/' rel='bookmark' title='ruby p3p协议'>ruby p3p协议</a></li>
<li><a href='http://www.gagahappy.com/rails-dev-production/' rel='bookmark' title='rails项目开发环境一定要与服务器生产环境一致'>rails项目开发环境一定要与服务器生产环境一致</a></li>
<li><a href='http://www.gagahappy.com/ruby-install-rmagick/' rel='bookmark' title='ruby 安装 rmagick'>ruby 安装 rmagick</a></li>
<li><a href='http://www.gagahappy.com/rails-redirect_to/' rel='bookmark' title='rails redirect_to'>rails redirect_to</a></li>
<li><a href='http://www.gagahappy.com/image_tag/' rel='bookmark' title='image_tag'>image_tag</a></li>
<li><a href='http://www.gagahappy.com/render-partial/' rel='bookmark' title='render partial'>render partial</a></li>
<li><a href='http://www.gagahappy.com/validates_inclusion_of/' rel='bookmark' title='validates_inclusion_of'>validates_inclusion_of</a></li>
<li><a href='http://www.gagahappy.com/ri-rails-api/' rel='bookmark' title='使用ri查看Rails的API'>使用ri查看Rails的API</a></li>
<li><a href='http://www.gagahappy.com/add-gem-sources/' rel='bookmark' title='为gem添加源'>为gem添加源</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.gagahappy.com/the-different-between-include-and-extend-in-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>安装Rmagick</title>
		<link>http://www.gagahappy.com/rmagick-install/</link>
		<comments>http://www.gagahappy.com/rmagick-install/#comments</comments>
		<pubDate>Thu, 14 Jul 2011 12:21:21 +0000</pubDate>
		<dc:creator>moonfox</dc:creator>
				<category><![CDATA[我爱Linux]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.gagahappy.com/?p=3755</guid>
		<description><![CDATA[首先下载imagemagick 进入安装目录 cd imagemagick ./configure &#8211;prefix=/opt/imagemagick make sudo make install 如果出现 /usr/bin/ld: cannot find -lperl 请安装 sudo apt-get install libperl-dev 您可能感兴趣的文章 ruby 中 include 与 extend 区别 解决rails2.2.2不能连接mysql 数据库驱动问题 rails3.0怪异的数据库密码配置 ruby 安装 rmagick rails redirect_to ruby 1.8.7 and rails 1.2.2完美匹配 render partial 安装 Sphinx 为gem添加源 strftime函数将时间格式化]]></description>
			<content:encoded><![CDATA[<p>首先下载imagemagick<br />
进入安装目录<br />
cd imagemagick<br />
./configure &#8211;prefix=/opt/imagemagick<br />
make<br />
sudo make install<br />
如果出现<br />
/usr/bin/ld: cannot find -lperl<br />
请安装<br />
sudo apt-get install libperl-dev</p>
<p>您可能感兴趣的文章<ol>
<li><a href='http://www.gagahappy.com/the-different-between-include-and-extend-in-ruby/' rel='bookmark' title='ruby 中 include 与 extend 区别'>ruby 中 include 与 extend 区别</a></li>
<li><a href='http://www.gagahappy.com/rails2-2-2-can-not-connect-mysql-drive-bug/' rel='bookmark' title='解决rails2.2.2不能连接mysql 数据库驱动问题'>解决rails2.2.2不能连接mysql 数据库驱动问题</a></li>
<li><a href='http://www.gagahappy.com/rails3-passwd-must-to-be-string-format/' rel='bookmark' title='rails3.0怪异的数据库密码配置'>rails3.0怪异的数据库密码配置</a></li>
<li><a href='http://www.gagahappy.com/ruby-install-rmagick/' rel='bookmark' title='ruby 安装 rmagick'>ruby 安装 rmagick</a></li>
<li><a href='http://www.gagahappy.com/rails-redirect_to/' rel='bookmark' title='rails redirect_to'>rails redirect_to</a></li>
<li><a href='http://www.gagahappy.com/ruby-1-8-7-and-rails-1-2-2/' rel='bookmark' title='ruby 1.8.7 and rails 1.2.2完美匹配'>ruby 1.8.7 and rails 1.2.2完美匹配</a></li>
<li><a href='http://www.gagahappy.com/render-partial/' rel='bookmark' title='render partial'>render partial</a></li>
<li><a href='http://www.gagahappy.com/install-sphinx/' rel='bookmark' title='安装 Sphinx'>安装 Sphinx</a></li>
<li><a href='http://www.gagahappy.com/add-gem-sources/' rel='bookmark' title='为gem添加源'>为gem添加源</a></li>
<li><a href='http://www.gagahappy.com/strftime/' rel='bookmark' title='strftime函数将时间格式化'>strftime函数将时间格式化</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.gagahappy.com/rmagick-install/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>为你的类混入Enumerable</title>
		<link>http://www.gagahappy.com/mix-enumerable-into-your-class/</link>
		<comments>http://www.gagahappy.com/mix-enumerable-into-your-class/#comments</comments>
		<pubDate>Sat, 26 Feb 2011 08:36:47 +0000</pubDate>
		<dc:creator>moonfox</dc:creator>
				<category><![CDATA[程序开发]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.gagahappy.com/?p=3049</guid>
		<description><![CDATA[在你的聚合类中混入Enumerable后，如果实现了 each 方法，并且为每个成员实现在了，那么你的类瞬间就拥有了 sort，max， min等方法，如果没有实现，你的类也具有了include，any，all等方法! 您可能感兴趣的文章 ruby 中 include 与 extend 区别 ruby initialize 返回对象 puts 返回值 rails3.0怪异的数据库密码配置 ruby 安装 rmagick ruby 类测试 小试重构 升级gem提示缺少no such file to load zlib belongs_to 选项中的:primary_key 为gem添加源]]></description>
			<content:encoded><![CDATA[<p>在你的聚合类中混入Enumerable后，如果实现了 each 方法，并且为每个成员实现在了<=>，那么你的类瞬间就拥有了 sort，max， min等方法，如果没有实现<=>，你的类也具有了include，any，all等方法!</p>
<p><a href="http://www.gagahappy.com/wp-content/uploads/2011/02/111.jpg"><img src="http://www.gagahappy.com/wp-content/uploads/2011/02/111.jpg" alt="" title="Enumerable" width="421" height="253" class="alignnone size-full wp-image-3050" /></a></p>
<p>您可能感兴趣的文章<ol>
<li><a href='http://www.gagahappy.com/the-different-between-include-and-extend-in-ruby/' rel='bookmark' title='ruby 中 include 与 extend 区别'>ruby 中 include 与 extend 区别</a></li>
<li><a href='http://www.gagahappy.com/ruby-initialize-back-class-self/' rel='bookmark' title='ruby initialize 返回对象'>ruby initialize 返回对象</a></li>
<li><a href='http://www.gagahappy.com/puts-back-value/' rel='bookmark' title='puts 返回值'>puts 返回值</a></li>
<li><a href='http://www.gagahappy.com/rails3-passwd-must-to-be-string-format/' rel='bookmark' title='rails3.0怪异的数据库密码配置'>rails3.0怪异的数据库密码配置</a></li>
<li><a href='http://www.gagahappy.com/ruby-install-rmagick/' rel='bookmark' title='ruby 安装 rmagick'>ruby 安装 rmagick</a></li>
<li><a href='http://www.gagahappy.com/ruby-%e7%b1%bb%e6%b5%8b%e8%af%95/' rel='bookmark' title='ruby 类测试'>ruby 类测试</a></li>
<li><a href='http://www.gagahappy.com/try-reconstruction/' rel='bookmark' title='小试重构'>小试重构</a></li>
<li><a href='http://www.gagahappy.com/update-gem-zlib/' rel='bookmark' title='升级gem提示缺少no such file to load zlib'>升级gem提示缺少no such file to load zlib</a></li>
<li><a href='http://www.gagahappy.com/belongs-to-primary-key/' rel='bookmark' title='belongs_to 选项中的:primary_key'>belongs_to 选项中的:primary_key</a></li>
<li><a href='http://www.gagahappy.com/add-gem-sources/' rel='bookmark' title='为gem添加源'>为gem添加源</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.gagahappy.com/mix-enumerable-into-your-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

