rbenv安装ruby2.3.0在线安装不上。老子出绝招了(更新)
摘要:今天把系统换成Linux mint了。感觉比ubuntu的好用太多,细节真是不错,Ubuntu感觉就是毛坯房,Linux mint真是精装修啊 问题来了。安装rbenv后,然后安装rbenv-build 然后安装 ruby 2.3.3,这时候,下载非常慢,终端需要单独配置FQ,然而。有时不好使,这时
阅读全文
posted @
2015-12-28 22:44
c3tc3tc3t
阅读(990)
推荐(0)
记录更新rbenv 和 ruby-build安装2.3的ruby注意细节
摘要:安装就不说了,官网有,但是今天发布了ruby2.3,所以更新一下进入.rbenv目录,执行git pull 更新,但是更新了rbenv,执行rbenv install -l 并没有最新的2.3.0 release版本。然后我观察ruby-build插件的git仓库,有2.3代码。怀疑这个也要更新,所...
阅读全文
posted @
2015-12-28 14:42
c3tc3tc3t
阅读(290)
推荐(0)
ruby中的reject和reject!
摘要:reject和reject!reject返回不满足代码块的元素数组reject!删除数组中满足代码块的元素a=[1,2,3,5]a.reject! {|x| x4}p cp b[1, 2, 3, 4][1, 2, 3, 4, 5]
阅读全文
posted @
2015-12-20 12:28
c3tc3tc3t
阅读(1020)
推荐(0)
ruby中将数组转换成hash
摘要:class Arraydef to_h(default=nil)Hash[ *inject([]) { |a, value| a.push value, default || yield(value) } ]endend看懂这个方法先理解这个p Hash[*[1,2,3,4]]打印出{1=>2, 3...
阅读全文
posted @
2015-12-19 22:42
c3tc3tc3t
阅读(706)
推荐(0)
ruby1.8到2.1语法改变
摘要:1定义hash的语法改变old_way = {:foo => "bar", :one => 1}new_way = {foo: "bar", one: 1}2 方法中传递hashdef some_method(hash = {})# do stuffendsome_method(:foo => "b...
阅读全文
posted @
2015-12-12 20:58
c3tc3tc3t
阅读(204)
推荐(0)
ruby api 2.1新增改变
摘要:-> 这个符号可以替换lambda%i 生成符号数组 %i(foor bar baz) #[:foo,:bar:baz]def 定义方法 eg: def foo(x: 1); puts; endhash {a:1,b:2}替换{:a=>1,:b=>2}r ...
阅读全文
posted @
2015-12-12 12:21
c3tc3tc3t
阅读(251)
推荐(0)
ruby中迭代器枚举器的理解
摘要:参考《ruby编程语言》5.3迭代器和可枚举对象迭代器一个迭代器是一个方法,这个方法里面有yield语句,这个方法里的yield语句,与传递给这个方法的块进行数据传输yield将数据传给代码快,代码块再把数据传输给yieldeach方法就是一个迭代器,里面有yield语句枚举器1 一个枚举器是Enu...
阅读全文
posted @
2015-12-12 00:34
c3tc3tc3t
阅读(415)
推荐(0)
注意,ruby循环体定义的变量在结束时后,变量还存在
摘要:a = [1, 2, 3]for i in a b = 123 p iendp "b:#{b}"p i《ruby语言编程》 129页 倒数 第8行
阅读全文
posted @
2015-12-04 13:34
c3tc3tc3t
阅读(142)
推荐(0)
ruby的hash学习笔记例: 将字符串文本中的单词存放在map中
摘要:text = 'The rain in Spain falls mainly in the plain.'first = Hash.new []second = Hash.new {|hash,key| hash[key] = []}text.split(/\W+/).each do |word|...
阅读全文
posted @
2015-12-01 21:44
c3tc3tc3t
阅读(403)
推荐(0)
ruby 字符串学习2
摘要:在一个ruby字符串中包含表但是或者变量。想使用不同的值替换表达式或者变量1 类似java 或者python的printf-style方式template = 'Oceania has always been at war with %s.'template % 'Eurasia' # => "Oc...
阅读全文
posted @
2015-11-30 14:00
c3tc3tc3t
阅读(174)
推荐(0)
ruby 字符串学习笔记1
摘要:1 从一种数据结构中构件字符串hash = { key1: "val1", key2: "val2" }string = ""hash.each { |k,v| string "The number is 5.""The number is #{5}."# => "The number is 5....
阅读全文
posted @
2015-11-30 13:25
c3tc3tc3t
阅读(349)
推荐(0)
rake 任务参数传递问题解决
摘要:原文 : https://robots.thoughtbot.com/how-to-use-arguments-in-a-rake-tasknamespace :tweets do desc 'Send some tweets to a user' task :send, [:username]...
阅读全文
posted @
2015-09-11 15:07
c3tc3tc3t
阅读(330)
推荐(0)
安装rails遇到的问题
摘要:1 要安装js运行环境,例如Nodejs,如果使用nvm记得,安装完执行nvm use '版本号'2或者在Gemfile文件中加入:gem 'execjs'gem 'therubyracer'然后bundle install,再去执行rails s就成功了。3修改Gemfile文件的source '...
阅读全文
posted @
2015-07-12 06:40
c3tc3tc3t
阅读(165)
推荐(0)
gem install mysql遇到问题。解决方案
摘要:今天遇到的问题,是使用gem install mysql遇到的。报下面的错误Building native extensions. This could take a while...ERROR: Error installing mysql2:ERROR: Failed to build gem ...
阅读全文
posted @
2015-07-10 15:49
c3tc3tc3t
阅读(243)
推荐(0)
动态定义一个方法
摘要:class A def self.testName(name, &block) define_method name do block.call end endendA.testName('jack') {p 'hello'}A.new.jack()
阅读全文
posted @
2015-06-17 22:06
c3tc3tc3t
阅读(340)
推荐(0)
设置webstorm的file watch 监视scss文件
摘要:参考:http://blog.founddrama.net/2013/04/watching-compass-files-in-webstorm/ 上面红色划线部分。 特别注意arguments: 像使用compass框架的配置文件。需要按图中设置 ubuntu下面配置
阅读全文
posted @
2015-06-02 22:39
c3tc3tc3t
阅读(981)
推荐(0)
ruby中的类实例变量和实例的实例变量
摘要:ruby中有实例变量这个语法,有点类似java的对象的属性,但是ruby中类也有实力变量,class Person @name = 'hello' def initialize(name,age) @name = name @age = age end def self.talk...
阅读全文
posted @
2015-04-27 21:33
c3tc3tc3t
阅读(272)
推荐(0)
读<<programming ruby>> 7.6节 flip-flop 理解
摘要:书中源码是这样的File.foreach('1.txt') do |x| if(($. == 1) || x =~ /eig/) .. (($. == 3) || x =~ /nin/) then print x endend其中 1.txt内容如下firstsecondthirdfour...
阅读全文
posted @
2015-04-22 12:25
c3tc3tc3t
阅读(297)
推荐(0)
ruby逻辑判断符号
摘要:putstrueandfalse#相当于(putstrue)andfalseUse &&/|| for boolean expressions, and/or for control flow. (Rule of thumb: If you have to use outer parentheses...
阅读全文
posted @
2015-04-22 09:24
c3tc3tc3t
阅读(257)
推荐(0)