Ruby学习

简介:

把复制一个文件到另一个文件,瞎折腾的,不知道不关闭有没有问题

1
File .open( ARGV [ 1 ], 'w' ).write( File .open( ARGV [ 0 ]).read())

网上查询了, File.open 会在代码块结束后自动close


加载模块

1
2
require  './Ex25'  #这个不能切换目录
require  File .expand_path( "../Ex25" , __FILE__ #这个可以切换目录


文件操作


NET-SSH 和 NET-SCP


Ruby代码规范


vim-ruby 

1
2
3
4
#ubuntu
echo  'map <F5> :!ruby % <CR>' sudo  tee  -a  /usr/share/vim/vim [0-9][0-9] /ftplugin/ruby .vim
#other
echo  'map <F5> :!ruby % <CR>' >> /usr/share/vim/vim [0-9][0-9] /ftplugin/ruby .vim


.vimrc

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
" 设置编码
  set  enc=utf-8
" 设置文件编码
set  fenc=utf-8
" 设置文件编码检测类型及支持格式
set  fencs=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
" 设置开启语法高亮
syntax on
"显示行号
set  number
" 查找结果高亮度显示
set  hlsearch
" tab宽度
set  tabstop=4
set  cindent shiftwidth=4
set  autoindent shiftwidth=4
filetype plugin indent on


编译安装ruby

1
2
3
4
5
6
7
8
sudo  apt-get -y  install  build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
cd  /tmp
wget http: //cache .ruby-lang.org /pub/ruby/2 .0 /ruby-2 .0.0-p353. tar .gz
tar  -xvzf ruby-2.0.0-p353. tar .gz
cd  ruby-2.0.0-p353/
. /configure  --prefix= /usr/local
make
sudo  make  install


安装rails

1
2
3
4
5
6
sudo  gem  install  rails
#install node.js
#sudo apt-get install python-software-properties python g++ make
#sudo add-apt-repository ppa:chris-lea/node.js
#sudo apt-get update
sudo  apt-get  install  nodejs



本文转自 nonono11 51CTO博客,原文链接:http://blog.51cto.com/abian/1335567,如需转载请自行联系原作者
相关文章
|
算法框架/工具 Ruby
我想学Ruby —— Ruby学习资源汇总
iwanttolearnruby 这个站点搜集了一些不错的 Ruby 学习资源,值得各位 Ruby爱好者参考。
170 0
我想学Ruby —— Ruby学习资源汇总
Ruby学习资源
这里是一些Ruby学习资源。 网站名称 网址 Ruby官方文档 https://www.ruby-lang.org/zh_cn/documentation/ Learning to Program https://pine.
954 0
|
Ruby 定位技术 Python
|
4月前
|
Ruby
|
4月前
|
JSON 数据格式 Ruby
|
4月前
|
调度 Ruby