随笔分类 - Ruby
ruby
摘要:构成 Integer Fixnum Bignum Float Rational(分子,分母) Complex(实数,虚数) 字面量 0(零)开头----八进制 0o开头----八进制 0x开头----十六进制 0d开头----十进制 0b开头----二进制 123....
阅读全文
摘要:创建(特殊的)Hash[]Hash[‘a’,1,’b’,2]->yesHash[‘a’,1,’b’,’b’]->noHash[[[‘a’,1],[‘b’,2]]]->yes删除delete (有个带if的条件删除)清除用clear遍历each开头的each {| key, value| block ...
阅读全文
摘要:[]中的索引 a = "hello there" a[1] #=> "e" a[2, 3] #=> "llo" a[2..3] #=> "ll" a[-3, 2] #=> "er" a[7..-2] #=> "her" a[-4..-2] #=> "her" a[-2..-4] #=...
阅读全文
摘要:定义二维数组: list = [['保密',''],['男',1],['女',0]] 引用 怎么创建与返回值是二维数组形式 不知道你想要怎样的答案 如果是一方法想要返回二维数组,方法的最后一行是那个数组就好了 def list [['保密',''],['男...
阅读全文
摘要:class Array Arrays are ordered, integer-indexed collections of any object. Array indexing starts at 0, as in C or Java. A negative index is assumed...
阅读全文
摘要:必备工具 irb 查祖先 1.9.3-p545 :023 > String.ancestors => [String, Comparable, Object, Kernel, BasicObject] String的前面有四个上级 过滤方法 Ruby的方法非常多,以至于不得...
阅读全文
摘要:Titlemap reduce select reject group_by each collect inject1. map:针对每个element进行变换并返回整个修改后的map例如有这样一个字符串: a = %w(a b cD) a.map do |item| item.upcase e...
阅读全文
摘要:Windows下pry安装和配置 pry是一个增强型的交互式命令行工具,比irb强大。 有自动完成功能,自动缩进,有颜色。有更强大的调试功能。 pry安装很简单。 在终端输入: gem install pry 然后就会自动到网上下载安装了。 设置 在windows上pry...
阅读全文
摘要:设置irb和ri 输入ruby -v查看是否能够显示ruby版本 现在可以 配置irb了. irb是交互式Ruby 的命令行工具,即输入一句就立即执行并给出结果. 默认的irb不够强大,现在给它配置一下. irb配置 放在个人目录下的.irbrc文件里(文件路径: %USERPROFI...
阅读全文
摘要:1.RubyInstaller在RubyInstaller官网下载window版本安装,地址:http://rubyinstaller.org/downloads/执行安装程序,勾选Add Ruby executables to your PATH,安装完成在cmd上测试ruby -v查看注意安装路...
阅读全文
摘要:Windows Ruby 安装步骤准备工作: 1.http://rubyinstaller.org/downloads/ 下载选择Ruby 1.9.32.http://rubyinstaller.org/downloads/ 下载DEVELOPMENT KIT 注意版...
阅读全文
摘要:在Ubuntu上安装LAMP此种方法在Linux Mint 13/14/15/16/17、Ubuntu 12.10(Quantal Quetzal)和Ubuntu 13.04 Raring Ringtail上屡试不爽。sudo apt-get install lamp-server^ 测试Apach...
阅读全文
摘要:Install Ruby(安装)For windows you can download Ruby fromhttp://rubyforge.org/frs/?group_id=167for Linux tryhttp://www.rpmfind.net.Our first program(从此开始...
阅读全文
摘要:Sublime2下载地址:http://www.sublimetext.com/downloadstep.1 解压下载的压缩包tar xf Sublime\ Text\ 2.0.2.tar.bz2 # 开始以外打错了,\ 表示空格,明白? step.2 把释放的内容移动到合适的位置,这里是/usr...
阅读全文
摘要:包的选择和配置想用RMagick,但据说内存泄露的问题比较厉害,作为替代品MiniMagick不存在内存泄露的问题。而二者都是使用ImageMagick的,所以需要下载并安装ImageMagick。下面安装ImageMagick:sudo apt-get install imagemagick安装g...
阅读全文
摘要:Install MongoDB on Debian¶This tutorial outlines the steps to installMongoDBon Debian systems. The tutorial uses.debpackages to install. While some De...
阅读全文
摘要:Mongois a document-oriented database.Install the required gems:gem install mongogem install bson_ext第一步,连接到mongo,可以在configure block完成。require 'sinatra'require 'mongo'require 'json/ext'include Mongoconfigure do conn=MongoClient.new('localhost',27017) set :mongo_connect
阅读全文
摘要:原文地址:https://ididitmyway.herokuapp.com/past/2010/3/30/superdo_a_sinatra_and_datamapper_to_do_list/这个tutorial说明:怎么构建一个list app,其中要用到数据库来保存task。tutorial概括以下技术:安装 SQLite and Datamapper连接数据库数据库中的CRUD 动作REST风格的urls我在这里主要做的是根据我的实际操作和理解,把整个过程用我熟悉的中国话记录下来,以便下次我还能根据它实现或修改这个App,仅此而已。开始tutorial前,确保已经安装了Sinatra
阅读全文
摘要:原文URL:http://www.rubycc.com/bbs/topic_detail/861.基础代码app.rbrequire 'rubygems'require 'sinatra/base' class App < Sinatra::Base get '/' do "Hello, World" endend注: ruby版本小于1.9, 必须在第一行加require 'rubygems'看清楚第二行require 'sinatra/base'这是一种基于类的router定义方式。2
阅读全文
摘要:URL: http://slim-lang.com/Example:doctype htmlhtml head title Slim Examples meta name="keywords" content="template language" meta name="author" content=author javascript: alert('Slim supports embedded javascript!') body h1 Markup examples #content p This example
阅读全文

浙公网安备 33010602011771号