<?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.sdgz.cn/category/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sdgz.cn</link>
	<description>PHP RUBY</description>
	<lastBuildDate>Tue, 03 Aug 2010 17:14:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>ruby内嵌表达式</title>
		<link>http://www.sdgz.cn/ruby-embedded-expression/</link>
		<comments>http://www.sdgz.cn/ruby-embedded-expression/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 21:50:17 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[内嵌表达式]]></category>

		<guid isPermaLink="false">http://www.sdgz.cn/?p=263</guid>
		<description><![CDATA[可以用#{}内嵌表达式，如： ruby&#62; var = &#8220; abc &#8221; &#8220; abc &#8221; ruby&#62; &#8220;1234#{var}5678&#8243; &#8220;1234 abc 5678&#8243;]]></description>
			<content:encoded><![CDATA[<p>可以用#{}内嵌表达式，如：</p>
<ol>
<li>ruby<strong><span style="color: #006699;">&gt;</span></strong> <span style="color: #ff0000;">var</span> = <span style="color: #0000ff;">&#8220; abc &#8221;</span></li>
<li>&#8220; abc &#8221;</li>
<li>ruby<strong><span style="color: #006699;">&gt;</span></strong> &#8220;1234#{var}5678&#8243;</li>
<li>&#8220;1234 abc 5678&#8243;</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.sdgz.cn/ruby-embedded-expression/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TOP5外包网站</title>
		<link>http://www.sdgz.cn/top5-outsourcing-website/</link>
		<comments>http://www.sdgz.cn/top5-outsourcing-website/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 10:07:30 +0000</pubDate>
		<dc:creator>leleba</dc:creator>
				<category><![CDATA[PHP学习]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[watir]]></category>
		<category><![CDATA[elance guru rentacoder getafreelancer scriptlance]]></category>

		<guid isPermaLink="false">http://www.sdgz.cn/top5-outsourcing-website/</guid>
		<description><![CDATA[1. eLance http://www.elance.com/ 2. Guru http://www.guru.com/ 3. RentACoder http://www.rentacoder.com/ 4. GetAFreelancer http://www.getafreelancer.com/ 5. ScriptLance http://www.scriptlance.com/]]></description>
			<content:encoded><![CDATA[<p><span style="TEXT-DECORATION: underline"><span style="COLOR: #0000ff">1. eLance <br/><a href="http://www.elance.com/">http://www.elance.com/</a></span></span></p>
<p><span style="TEXT-DECORATION: underline"><span style="COLOR: #0000ff">2. Guru <br/><a href="http://www.guru.com/">http://www.guru.com/</a></span></span></p>
<p><span style="TEXT-DECORATION: underline"><br/>3. RentACoder <br/><a href="http://www.rentacoder.com/">http://www.rentacoder.com/</a></span></p>
<p><br/>4. GetAFreelancer <br/><a href="http://www.getafreelancer.com/">http://www.getafreelancer.com/</a></p>
<p>5. ScriptLance <br/><a href="http://www.scriptlance.com/">http://www.scriptlance.com/</a></p>
<p/>
]]></content:encoded>
			<wfw:commentRss>http://www.sdgz.cn/top5-outsourcing-website/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ruby的url解码函数和url编码函数</title>
		<link>http://www.sdgz.cn/ruby-of-the-url-decoding-function-and-url-encoding-function/</link>
		<comments>http://www.sdgz.cn/ruby-of-the-url-decoding-function-and-url-encoding-function/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 11:08:18 +0000</pubDate>
		<dc:creator>leleba</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[url解码　url编码]]></category>

		<guid isPermaLink="false">http://www.sdgz.cn/ruby-of-the-url-decoding-function-and-url-encoding-function/</guid>
		<description><![CDATA[含中文字符的url是一些乱码，如中文&#8221;个&#8221;，在url中表示为&#8221;％b8%f6&#8243;。有时需要进行url解码和编码，两个函数如下： def URLDecode(str) str.gsub!(/%[a-fA-F0-9]{2}/) { &#124;x&#124; x = x[1..2].hex.chr } end def URLEncode(str) str.gsub!(/[^\w$&#38;\-+.,\/:;=?@]/) { &#124;x&#124; x = format(&#8220;%%%x&#8220;, x[0]) } end]]></description>
			<content:encoded><![CDATA[<p>含中文字符的url是一些乱码，如中文&#8221;个&#8221;，在url中表示为&#8221;％b8%f6&#8243;。有时需要进行url解码和编码，两个函数如下：</p>
<p><span style="COLOR: green">def</span> <span style="COLOR: blue">URLDecode</span><span style="COLOR: olive">(</span><span style="COLOR: blue">str</span><span style="COLOR: olive">)</span><span style="COLOR: gray"><br/></span> <span style="COLOR: blue">str</span><span style="COLOR: gray">.</span><span style="COLOR: blue">gsub</span><span style="COLOR: gray">!</span><span style="COLOR: olive">(</span><span style="COLOR: #8b0000">/</span><span style="COLOR: red">%[a-fA-F0-9]{2}</span><span style="COLOR: #8b0000">/</span><span style="COLOR: olive">)</span> <span style="COLOR: gray">{ |</span><span style="COLOR: blue">x</span><span style="COLOR: gray">|</span> <span style="COLOR: blue">x</span> <span style="COLOR: gray">=</span> <span style="COLOR: blue">x</span><span style="COLOR: olive">[</span><span style="COLOR: maroon">1..2</span><span style="COLOR: olive">]</span><span style="COLOR: gray">.</span><span style="COLOR: blue">hex</span><span style="COLOR: gray">.</span><span style="COLOR: blue">chr</span> <span style="COLOR: gray">} <br/></span><span style="COLOR: green">end</span><span style="COLOR: gray"><br/><br/></span> <span style="COLOR: green">def</span> <span style="COLOR: blue">URLEncode</span><span style="COLOR: olive">(</span><span style="COLOR: blue">str</span><span style="COLOR: olive">)</span><span style="COLOR: gray"><br/></span> <span style="COLOR: blue">str</span><span style="COLOR: gray">.</span><span style="COLOR: blue">gsub</span><span style="COLOR: gray">!</span><span style="COLOR: olive">(</span><span style="COLOR: #8b0000">/</span><span style="COLOR: red">[^</span><span style="COLOR: navy">\w</span><span style="COLOR: red">$&amp;</span><span style="COLOR: navy">\-</span><span style="COLOR: red">+.,</span><span style="COLOR: navy">\/</span><span style="COLOR: red">:;=?@]</span><span style="COLOR: #8b0000">/</span><span style="COLOR: olive">)</span> <span style="COLOR: gray">{ |</span><span style="COLOR: blue">x</span><span style="COLOR: gray">|</span> <span style="COLOR: blue">x</span> <span style="COLOR: gray">=</span> <span style="COLOR: blue">format</span><span style="COLOR: olive">(</span><span style="COLOR: #8b0000">&#8220;</span><span style="COLOR: red">%%%x</span><span style="COLOR: #8b0000">&#8220;</span><span style="COLOR: gray">,</span> <span style="COLOR: blue">x</span><span style="COLOR: olive">[</span><span style="COLOR: maroon">0</span><span style="COLOR: olive">])</span> <span style="COLOR: gray">} <br/></span><span style="COLOR: green">end</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sdgz.cn/ruby-of-the-url-decoding-function-and-url-encoding-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>给ruby程序以及ruby待操作的文件以完整的路径</title>
		<link>http://www.sdgz.cn/to-the-ruby-and-the-ruby-process-to-be-operated-with-the-full-path-to-the-file/</link>
		<comments>http://www.sdgz.cn/to-the-ruby-and-the-ruby-process-to-be-operated-with-the-full-path-to-the-file/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 07:32:15 +0000</pubDate>
		<dc:creator>leleba</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[文件操作　路径]]></category>

		<guid isPermaLink="false">http://www.sdgz.cn/to-the-ruby-and-the-ruby-process-to-be-operated-with-the-full-path-to-the-file/</guid>
		<description><![CDATA[有的时候需要给ruby程序以及ruby待操作的文件以完整的路径，举例说明吧： 在g:\ding\anpc\163_anpc.rb程序中有如下代码： 3.times { load &#8216;..\anpc\data_163.rb&#8217; load &#8216;..\bin\bin_163.rb&#8217; } 如果在g:\ding\anpc\ 下执行163_anpc.rb,　程序可以正常运行，但如果在别的路径，比如c:\，执行g:\ding\anpc\163_anpc.rb，程序就会报错，说找不到data_163.rb和bin_163.rb。 解决问题的方法是给ruby程序以完整的路径，如下所示： 3.times { load File.join(File.dirname(__FILE__), &#8216;data_163.rb&#8217;) load File.join(File.dirname(__FILE__), &#8216;../bin/bin_163.rb&#8217;) } 类似的例子： 在g:\ding\anpc\data_163.rb程序中有如下代码： #初始化user users = [] File.open(&#8216;user_163_anpc.txt&#8217;) do &#124;f&#124; f.each_line do &#124;line&#124; words = line.split(&#8216; &#8216;) users &#60;&#60; {:user =&#62; words[0], :password =&#62; words[1]} end end 该程序在g:\ding\anpc\ 下执行data_163.rb,　文件操作正常，但如果在别的路径，比如c:\，执行g:\ding\anpc\data_163.rb，程序就会报错，说找不到文件user_163_anpc.txt。 解决问题的方法是给待操作的文件以完整的路径，如下所示： #初始化user users = [] users_filename [...]]]></description>
			<content:encoded><![CDATA[<p>有的时候需要给ruby程序以及ruby待操作的文件以完整的路径，举例说明吧：</p>
<p>在g:\ding\anpc\163_anpc.rb程序中有如下代码：</p>
<p>3.times { <br/>load &#8216;..\anpc\data_163.rb&#8217; <br/>load &#8216;..\bin\bin_163.rb&#8217; <br/>}</p>
<p>如果在g:\ding\anpc\ 下执行163_anpc.rb,　程序可以正常运行，但如果在别的路径，比如c:\，执行g:\ding\anpc\163_anpc.rb，程序就会报错，说找不到data_163.rb和bin_163.rb。</p>
<p>解决问题的方法是给ruby程序以完整的路径，如下所示：</p>
<p>3.times { <br/>load File.join(File.dirname(__FILE__), &#8216;data_163.rb&#8217;) <br/>load File.join(File.dirname(__FILE__), &#8216;../bin/bin_163.rb&#8217;) <br/>}</p>
<p>类似的例子：</p>
<p>在g:\ding\anpc\data_163.rb程序中有如下代码：</p>
<p>#初始化user <br/>users = [] <br/>File.open(&#8216;user_163_anpc.txt&#8217;) do |f| <br/>f.each_line do |line| <br/>words = line.split(&#8216; &#8216;) <br/>users &lt;&lt; {:user =&gt; words[0], :password =&gt; words[1]} <br/>end <br/>end</p>
<p>该程序在g:\ding\anpc\ 下执行data_163.rb,　文件操作正常，但如果在别的路径，比如c:\，执行g:\ding\anpc\data_163.rb，程序就会报错，说找不到文件user_163_anpc.txt。</p>
<p>解决问题的方法是给待操作的文件以完整的路径，如下所示：</p>
<p>#初始化user <br/>users = [] <br/>users_filename = File.join(File.dirname(__FILE__), &#8216;user_sina_anpc.txt&#8217;) <br/>File.open(users_filename) do |f| <br/>f.each_line do |line| <br/>words = line.split(&#8216; &#8216;) <br/>users &lt;&lt; {:user =&gt; words[0], :password =&gt; words[1]} <br/>end <br/>end</p>
<p>本文原创于<a href="http://www.sdgz.cn"><span style="COLOR: #000000">：</span>http://www.sdgz.cn</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sdgz.cn/to-the-ruby-and-the-ruby-process-to-be-operated-with-the-full-path-to-the-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby字符处理的几个实例</title>
		<link>http://www.sdgz.cn/rubyzi-fu-chu-li-de-ji-ge-shi-li/</link>
		<comments>http://www.sdgz.cn/rubyzi-fu-chu-li-de-ji-ge-shi-li/#comments</comments>
		<pubDate>Tue, 05 May 2009 12:01:49 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[字符匹配]]></category>
		<category><![CDATA[字符处理]]></category>
		<category><![CDATA[汉字字符]]></category>

		<guid isPermaLink="false">http://www.sdgz.cn/?p=249</guid>
		<description><![CDATA[Ruby的字符处理能力是比较强大的，以下是我利用ruby处理汉字字符时摸索出的几个实例： 删除： char = “查看位置 某路某小区” char = char.delete(&#8216;查看位置&#8217;) 其中char来源于网页，有的时候会显示乱码，可能是网页和文本编辑器的编码不一样造成的。 这时可以使用： char = char[８ .. 996] 截取： char = “3室2厅1厨1卫2阳台” 想截取“3室”中的“３”、“2厅”中的“2”和“1卫”中的“1” char_1 = char[0,1] char_4 = char[3,1] char_10 = char[9,1] 匹配： if (char_1　=~ 　/3/) &#038;&#038; (char_4　=~ 　/2/) &#038;&#038; (char_10　=~ 　/1/) ie152.radio(:id, /3室2厅1卫/).set end 本文原创于 http://www.sdgz.cn，转摘请注明出处。]]></description>
			<content:encoded><![CDATA[<p>Ruby的字符处理能力是比较强大的，以下是我利用ruby处理汉字字符时摸索出的几个实例：</p>
<p>删除：<br />
char = “查看位置  某路某小区”<br />
char = char.delete(&#8216;查看位置&#8217;)<br />
其中char来源于网页，有的时候会显示乱码，可能是网页和文本编辑器的编码不一样造成的。<br />
这时可以使用：<br />
char = char[８ .. 996]</p>
<p>截取：<br />
char = “3室2厅1厨1卫2阳台”<br />
想截取“3室”中的“３”、“2厅”中的“2”和“1卫”中的“1”<br />
char_1 = char[0,1]<br />
char_4 = char[3,1]<br />
char_10 = char[9,1]</p>
<p>匹配：<br />
if (char_1　=~ 　/3/) &#038;&#038; (char_4　=~ 　/2/) &#038;&#038; (char_10　=~ 　/1/)<br />
  ie152.radio(:id, /3室2厅1卫/).set<br />
end</p>
<p>本文原创于 http://www.sdgz.cn，转摘请注明出处。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sdgz.cn/rubyzi-fu-chu-li-de-ji-ge-shi-li/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ruby添加字符串到文件</title>
		<link>http://www.sdgz.cn/rubytian-jia-zi-fu-chuan-dao-wen-jian/</link>
		<comments>http://www.sdgz.cn/rubytian-jia-zi-fu-chuan-dao-wen-jian/#comments</comments>
		<pubDate>Mon, 27 Apr 2009 11:16:13 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[添加字符串]]></category>

		<guid isPermaLink="false">http://www.sdgz.cn/?p=248</guid>
		<description><![CDATA[ruby添加字符串到文件比较tricky,我用的代码如下: file = File.open(&#8220;test.txt&#8221;, &#8220;a&#8221;) ie111.image(:class => /xyz/, :index => 1).click html1 = ie111.text_field(:id, &#8220;html_box&#8221;).value file]]></description>
			<content:encoded><![CDATA[<p>ruby添加字符串到文件比较tricky,我用的代码如下:</p>
<p>file = File.open(&#8220;test.txt&#8221;, &#8220;a&#8221;)<br />
ie111.image(:class => /xyz/, :index => 1).click<br />
html1 = ie111.text_field(:id, &#8220;html_box&#8221;).value<br />
file << html1<br />
file.close</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sdgz.cn/rubytian-jia-zi-fu-chuan-dao-wen-jian/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

