<?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="https://blog.gmem.cc/category/work/ruby/feed" rel="self" type="application/rss+xml" />
	<link>https://blog.gmem.cc</link>
	<description></description>
	<lastBuildDate>Mon, 06 Apr 2026 12:46:48 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.9.14</generator>
	<item>
		<title>RubyMine知识集锦</title>
		<link>https://blog.gmem.cc/rubymine-faq</link>
		<comments>https://blog.gmem.cc/rubymine-faq#comments</comments>
		<pubDate>Wed, 02 Mar 2016 01:22:07 +0000</pubDate>
		<dc:creator><![CDATA[Alex]]></dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[IntelliJ]]></category>

		<guid isPermaLink="false">https://blog.gmem.cc/?p=11733</guid>
		<description><![CDATA[<p>简介 RubyMine是一款基于IntelliJ平台的IDE，用于Ruby以及Ruby on Rails开发。该IDE内置了对JavaScript、HTML等Web开发技术的支持。 全局设置 设置路径 说明 L &#38; F ⇨ Ruby SDK &#38; Gems 可以管理Ruby SDK，点击按钮可以添加SDK，点击按钮可以设置当前工程使用的SDK 点击右侧窗格中的则可以为某个SDK安装Gem 常见问题 无法安装调试需要的Gem Ubuntu 14.04下，调试时RubyMine提示：The gem <a class="read-more" href="https://blog.gmem.cc/rubymine-faq">[...]</a></p>
<p>The post <a rel="nofollow" href="https://blog.gmem.cc/rubymine-faq">RubyMine知识集锦</a> appeared first on <a rel="nofollow" href="https://blog.gmem.cc">绿色记忆</a>.</p>
]]></description>
				<content:encoded><![CDATA[<div class="wri_content_clear_both"><div class="blog_h2"><span class="graybg">简介</span></div>
<p>RubyMine是一款基于IntelliJ平台的IDE，用于Ruby以及Ruby on Rails开发。该IDE内置了对JavaScript、HTML等Web开发技术的支持。</p>
<div class="blog_h2"><span class="graybg">全局设置</span></div>
<table class=" full-width">
<thead>
<tr>
<td style="width: 25%; text-align: center;">设置路径</td>
<td style="text-align: center;">说明</td>
</tr>
</thead>
<tbody>
<tr>
<td>L &amp; F ⇨ Ruby SDK &amp; Gems</td>
<td>
<p>可以管理Ruby SDK，点击按钮<img class="aligncenter size-full wp-image-11736 inlineBlock" src="https://blog.gmem.cc/wp-content/uploads/2016/03/Selection_003.png" alt="Selection_003" width="15" height="16" />可以添加SDK，点击按钮<img class="aligncenter size-full wp-image-11737 inlineBlock" src="https://blog.gmem.cc/wp-content/uploads/2016/03/Selection_004.png" alt="Selection_004" width="15" height="13" />可以设置当前工程使用的SDK</p>
<p>点击右侧窗格中的<img class="aligncenter size-full wp-image-11736 inlineBlock" src="https://blog.gmem.cc/wp-content/uploads/2016/03/Selection_003.png" alt="Selection_003" width="15" height="16" />则可以为某个SDK安装Gem</p>
</td>
</tr>
</tbody>
</table>
<div class="blog_h2"><span class="graybg">常见问题</span></div>
<div class="blog_h3"><span class="graybg">无法安装调试需要的Gem</span></div>
<p>Ubuntu 14.04下，调试时RubyMine提示：The gem debase required by the debugger is not currently installed. would you like to install it ?</p>
<p>点击Yes后，安装失败，提示： ERROR: Failed to build gem native extension ... Installing base gem Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources</p>
<p>解决方法一，使用非HTTPS源：</p>
<pre class="crayon-plain-tag">gem source -r https://rubygems.org/
gem source -a http://rubygems.org/</pre>
<p>解决方法二，安装libssl-dev并重新构建Ruby：</p>
<pre class="crayon-plain-tag">sudo apt-get install libssl-dev
cd ruby-2.1.9
./configure prefix=/home/alex/Ruby/2.1.9
make clean
make &amp;&amp; make install</pre>
<p>&nbsp;</p>
<p>&nbsp;</p>
</div><p>The post <a rel="nofollow" href="https://blog.gmem.cc/rubymine-faq">RubyMine知识集锦</a> appeared first on <a rel="nofollow" href="https://blog.gmem.cc">绿色记忆</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://blog.gmem.cc/rubymine-faq/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby学习笔记</title>
		<link>https://blog.gmem.cc/ruby-study-note</link>
		<comments>https://blog.gmem.cc/ruby-study-note#comments</comments>
		<pubDate>Sat, 01 Mar 2014 01:59:33 +0000</pubDate>
		<dc:creator><![CDATA[Alex]]></dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">https://blog.gmem.cc/?p=14172</guid>
		<description><![CDATA[<p>简介 Ruby是一门开源的动态语言，专注于简单和高生产力，它的语法优雅，易于编写也易于阅读。Ruby由日本人Matz编写，首次发布于1995年。 基本特性 万物皆对象 在语言设计初期，Matz就希望Ruby是一门比Perl更强大，而比Python更加OO的语言。Ruby中万物皆为对象，没有经典OO语言中所谓的基本类型： [crayon-69d48a08ce7ee581835130/] 高度灵活 Ruby允许开发人员修改甚至移除它最基本的语言特征。例如你可以随时为内置类型添加新方法： [crayon-69d48a08ce7f2081269980/] 块（Blocks） Ruby引入了块语法，开发人员可以用它来为任何方法引入闭包： [crayon-69d48a08ce7f5296891478/] 上面这个例子中， 块的范围由[crayon-69d48a08ce7f7805614803-i/] 限定。map方法则把块应用到列表中的每一个字符串，进而生成新的列表。 混入（Mixins） Ruby使用单继承，但是同时引入了模块（Modules）的机制，模块就是一系列方法的集合。 一个类可以混入一个模块，这样就拥有了模块中的所有方法。在Ruby中，任何实现了each方法的类，都可以混入Enumerable模块： [crayon-69d48a08ce7f9278538487/] 而Enumerable中的方法会调用each完成遍历操作。 变量 使用Ruby时，你不需要声明变量，它使用简单的前缀来区分变量的作用域： 变量 作用域 <a class="read-more" href="https://blog.gmem.cc/ruby-study-note">[...]</a></p>
<p>The post <a rel="nofollow" href="https://blog.gmem.cc/ruby-study-note">Ruby学习笔记</a> appeared first on <a rel="nofollow" href="https://blog.gmem.cc">绿色记忆</a>.</p>
]]></description>
				<content:encoded><![CDATA[<div class="wri_content_clear_both"><div class="blog_h1"><span class="graybg">简介</span></div>
<p>Ruby是一门开源的动态语言，专注于简单和高生产力，它的语法优雅，易于编写也易于阅读。Ruby由日本人Matz编写，首次发布于1995年。</p>
<div class="blog_h2"><span class="graybg">基本特性</span></div>
<div class="blog_h3"><span class="graybg">万物皆对象</span></div>
<p>在语言设计初期，Matz就希望Ruby是一门比Perl更强大，而比Python更加OO的语言。Ruby中万物皆为对象，没有经典OO语言中所谓的基本类型：</p>
<pre class="crayon-plain-tag">5.times { print "Hello Ruby\n" }</pre>
<div class="blog_h3"><span class="graybg">高度灵活</span></div>
<p>Ruby允许开发人员修改甚至移除它最基本的语言特征。例如你可以随时为内置类型添加新方法：</p>
<pre class="crayon-plain-tag">class Numeric
    def plus(x)
        self.+(x)
    end
end


class Main
    print(5.plus 6)  # 11
end</pre>
<div class="blog_h3"><span class="graybg">块（Blocks）</span></div>
<p>Ruby引入了块语法，开发人员可以用它来为任何方法引入闭包：</p>
<pre class="crayon-plain-tag">search_engines =
    %w[Google Yahoo MSN].map do |engine|
        'http://www.' + engine.downcase + '.com'
    end
print(search_engines) # ["http://www.google.com", "http://www.yahoo.com", "http://www.msn.com"]</pre>
<p>上面这个例子中， 块的范围由<pre class="crayon-plain-tag">do ... end</pre> 限定。map方法则把块应用到列表中的每一个字符串，进而生成新的列表。</p>
<div class="blog_h3"><span class="graybg">混入（Mixins）</span></div>
<p>Ruby使用单继承，但是同时引入了模块（Modules）的机制，模块就是一系列方法的集合。</p>
<p>一个类可以混入一个模块，这样就拥有了模块中的所有方法。在Ruby中，任何实现了each方法的类，都可以混入Enumerable模块：</p>
<pre class="crayon-plain-tag">class MyArray
    include Enumerable
end</pre>
<p>而Enumerable中的方法会调用each完成遍历操作。</p>
<div class="blog_h3"><span class="graybg">变量</span></div>
<p>使用Ruby时，你不需要声明变量，它使用简单的前缀来区分变量的作用域：</p>
<table class=" full-width fixed-word-wrap">
<thead>
<tr>
<td style="width: 20%; text-align: center;">变量</td>
<td style="text-align: center;">作用域</td>
</tr>
</thead>
<tbody>
<tr>
<td>var</td>
<td>可以是一个局部变量</td>
</tr>
<tr>
<td>@var</td>
<td>实例变量</td>
</tr>
<tr>
<td>$var</td>
<td>全局变量</td>
</tr>
</tbody>
</table>
<p> 这种约定让开发人员很容易区分变量的用途，而且，访问实例成员时，你也不需要self.前缀。</p>
<div class="blog_h3"><span class="graybg">其它特性</span></div>
<table class=" full-width fixed-word-wrap">
<tbody>
<tr>
<td>支持异常处理机制</td>
</tr>
<tr>
<td>支持基于标记-清除算法的垃圾回收机制</td>
</tr>
<tr>
<td>在Ruby中编写C扩展比Perl或者Python中容易。在C中通过API调用Ruby也很简单</td>
</tr>
<tr>
<td>可以动态的加载扩展库</td>
</tr>
<tr>
<td>支持OS无关的线程机制</td>
</tr>
<tr>
<td>高可移植性</td>
</tr>
</tbody>
</table>
<div class="blog_h1"><span class="graybg">安装和配置</span></div>
<div class="blog_h2"><span class="graybg">Ubuntu</span></div>
<pre class="crayon-plain-tag">wget https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.3.tar.gz
sudo apt install -y libyaml-dev libssl-dev
xzf ruby-2.3.3.tar.gz
cd ruby-2.3.3
./configure --prefix=/home/alex/Ruby/2.3.3
make &amp;&amp; make install</pre>
<div class="blog_h2"><span class="graybg">配置</span></div>
<p>首先需要设置环境变量，把$RUBY_HOME/bin加入到$PATH中。</p>
<p>默认的RubyGems镜像速度比较慢，可以改用国内镜像： </p>
<pre class="crayon-plain-tag"># 因本机不信任ruby-china的证书签发机构StartCom，因此无法使用其https源，你如果信任，可以把下面的http改为https
gem sources --add http://gems.ruby-china.org/ --remove https://rubygems.org/
gem sources -l
# 确保输出中只有新添加的国内镜像</pre>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</div><p>The post <a rel="nofollow" href="https://blog.gmem.cc/ruby-study-note">Ruby学习笔记</a> appeared first on <a rel="nofollow" href="https://blog.gmem.cc">绿色记忆</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://blog.gmem.cc/ruby-study-note/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
