构造字符串字面量方法一:最简单的使用单引号或者双引号括起来的字符串,比如"hello"。方法二:使用%q配合分界符,%q代表单引号str=%q!he/lo!方法三:使用%Q配合分界符,%Q代表双引号str=%Q{he/lo}方法四:here document构建字符串,该方法比较适合用于多行字符串的...
分类:
其他好文 时间:
2014-06-27 15:17:01
阅读次数:
247
赋值:ruby支持并行赋值,即允许在赋值表达式中出现多余一个值和多于一个的变量:x,y=1,2a,b=b,ax,y,z=[1,2,3](python同样可以正常上面的语句)。Methods in Ruby are allowed to return more than one value, and ...
分类:
编程语言 时间:
2014-06-27 13:30:46
阅读次数:
225
模块模块同类一样,也有 class method 和 instance method。module 没有new不能生成实例对象其中 class method 在模块中称为模块方法,是可以直接调用的。module Foo
def self.hello
puts 'hello world!'
end
def Foo.dear #module全局作用域内的self还是没有变,就是...
分类:
其他好文 时间:
2014-06-26 14:19:28
阅读次数:
163
PuppetDB安装
#######################################
2014年6月23日 10:25:36
一、安装要求:
1.JDK1.7或以上版本
2.Puppet3.5.1或更高版本
3.Puppet已配置执行Puppet agent --test没有问题
二、安装步骤
1.puppet源配置好
2.apt-get install pupp...
分类:
数据库 时间:
2014-06-25 19:28:48
阅读次数:
285
安装CocoaPods 是用 Ruby 实现的,所以使用它需要用到 Ruby 环境。Ruby 的官方软件源使用的是亚马逊的云服务,在国内访问有问题,需要将官方的源替换成国内淘宝提供的源。# 更新 Ruby 软件源gem sources --remove https://rubygems.org/ge...
分类:
其他好文 时间:
2014-06-25 18:50:41
阅读次数:
239
ruby comes with a set of predefined variables$: = default search path (array of paths)其他Ruby特殊变量:$! 最近一次的错误信息$@ 错误产生的位置$_ gets最近读的字符串$. 解释器最近读的行数(line...
分类:
其他好文 时间:
2014-06-25 13:55:51
阅读次数:
179
团队已经决定逐步由java转向scala。现在的项目已经使用了几种编程语言。Java为主,ruby做代码生成器,python做安装脚本和命令行工具。其实从ruby和python的使用经验中,已经或多或少地接触到了FP的概念。Scala旗帜鲜明地在Java上增加了FP的功能,观念的冲突和复杂的语法让其...
分类:
其他好文 时间:
2014-06-25 11:36:19
阅读次数:
323
CentOS安装Puppet
环境介绍:centos6.4x64 采用CentOS-6.4-x86_64-minimal.iso最小化安装
puppet版本3.6.2,ruby1.8.7,facter1.7.1
安装过程:1,关闭selinux
2,添加puppet安装源 rpm -ivh
htt...
分类:
其他好文 时间:
2014-06-24 22:36:51
阅读次数:
256
1.Could not find gem 'sqlite3 (>= 0)' in any of the gem sources listed in you
r Gemfile
2.ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /usr/local/lib/ruby/gems/1.9.1 director.y
3.rails 3遇到 Could n...
分类:
其他好文 时间:
2014-06-24 22:18:45
阅读次数:
316
一.创建一个新的应用程序
在控制台输入
> rails new demo
create
create README.rdoc
create Rakefile
create config.ru
create .gitignore
create Gemfile
create app
....
分类:
其他好文 时间:
2014-06-24 20:51:22
阅读次数:
281