Time of Update: 2014-12-15
標籤:http io ar os 使用 sp on bs ad 我們時常會與作業系統互動或在 Ruby 中執行 Shell 命令。Ruby為我們提供了完成該任務的諸多方法。ExecKernel#
Time of Update: 2015-02-04
標籤:最近在接手一個手機項目。在搭建環境的過程中,遇到了一些問題,在下文中已做記錄,並奉上個人的解決方案。開發環境 win2003 ; JetBrains RubyMine6.3.3 1、 下載最新版ruby,(rubyinstaller-2.0.0-p598.exe ,最新版)官網:http://rubyinstaller.org/downloads/2、 安裝ruby雙擊安裝,安裝過程出現如下介面。這裡我們選擇安裝路徑為 D:\Ruby200。
Time of Update: 2015-01-30
標籤:Ruby 安裝從原始碼在windows下安裝Ruby是非常苦逼的差事,可以從http://rubyinstaller.org/或者 http://railsinstaller.org/ 下載已經打包好的安裝程式。Ruby配置在windows中配置環境變數RUBY_HOME=rubyinstaller_dir (實際的ruby所在路徑)在path中添加 %RUBY_HOME%\bin在命令列下運行 ruby
Time of Update: 2015-02-24
標籤:puts "Please input Number1: "#提示輸入第一個數number1=gets#儲存第一個數puts "Please input an operator(+,-,*,/): "op=getsputs "Please input Number2: "number2=getscase op.chomp#根據運算子執行相應的運算when
Time of Update: 2015-01-19
標籤:ruby passenger nginx 本文介紹如何使用Nginx+Passenger來部署Ruby on Rails環境本文使用的作業系統版本是CentOS6.51.安裝ruby wget http://cache.ruby-lang.org/pub/ruby/ruby-2.0.0-p594.tar.gz mkdir -p /
Time of Update: 2015-01-14
標籤:步驟1安裝homebrew, 通過它安裝系統所需要的包ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)"安裝完成後,brew doctor 自檢一下步驟2安裝curl -L https://get.rvm.io | bash -s stablesource ~/.rvm/scripts/rvm$ rvm -vrvm 1.26.4 (master) by Wayne E. Seguin
Time of Update: 2015-01-09
標籤:ruby on rails一、環境安裝centos 作業系統1、安裝rvmcurl -sSL https://get.rvm.io | bash -s stable rvm -v查看是否安裝成功2、安裝rubyrvm install 1.9.3ruby -v 查看ruby版本號碼Rvm命令簡單使用介紹: rvm install ruby &
Time of Update: 2015-01-05
標籤:ruby wc 統計單詞數和行數等 在Ruby中我們定義一個wc方法,用來統計檔案中出現的文本行數、單詞數和字元數,ruby代碼程式如下:def wc(filename) nline = nword = nchar = 0 File.open(filename) do
Time of Update: 2014-12-27
標籤:vagrant配置 開篇我只想吐槽為社麼我沒有早點瞭解vagrant呢,這樣我就能省那筆買 MacBook Pro 的錢了。。。 “Create and configure lightweight,reproducible and portable development
Time of Update: 2014-12-21
標籤:需求:商場收銀軟體,根據客戶購買物品的單價和數量,計算費用,會有促銷活動,打八折,滿三百減一百之類的。一,使用原廠模式。# -*- encoding: utf-8 -*-#現金收費抽象類別class CashSuper def accept_cash(money) endend#正常收費子類class CashNormal < CashSuper def accept_cash(money) money endend#打折收費子類class
Time of Update: 2014-12-21
標籤:之前有看過《ruby設計模式》,不過漸漸的都忘記了。現在買了一個大話設計模式,看起來不是那麼枯燥,順便將代碼用ruby實現了一下。 # -*- encoding: utf-8 -*-#運算類class Operation attr_accessor :number_a,:number_b def initialize(number_a = nil, number_b = nil) @number_a = number_a
Time of Update: 2014-12-18
標籤:des style ar io color os sp for strong IDE: Jetbrains
Time of Update: 2014-12-12
標籤:style http io ar color sp for on bs ruby -v驗證ruby是否安裝成功並查看版本號碼 ruby -e "puts
Time of Update: 2014-12-11
標籤:style blog color 使用 sp 資料 div log bs #數字分為認證Integer,浮點數Float(對應與其他語言中的double),和複數Complex#整數又分為
Time of Update: 2014-12-11
標籤:style blog ar color os 使用 sp for java #Ruby內建基礎資料類型
Time of Update: 2014-12-04
標籤:blog http ar os sp for on 檔案 資料 這裡簡單加上幾個驗證,非空,最小長度,唯一修改模型修改app/models/post.rb檔案,如下:class Post
Time of Update: 2014-12-04
標籤:des blog http io ar os sp on 檔案 首先需要在index頁加個刪除連結,並提供一個刪除的確認,使用者確認刪除時,直接刪除資料。修改views修改 ap
Time of Update: 2014-12-01
標籤:ruby zip 壓縮解壓 在UNIX下的我們怎麼會淪落到用ruby寫壓縮和解壓工具呢?直接上shell啊!但是請允許本貓這次可恥的用ruby來玩玩吧!其實ruby GEM中有很多壓縮解壓包,我選的是Zip,也許是因為名字元合KISS原則吧!不過在編寫中發現Zip中的某些類沒有文檔中所說明的執行個體方法,也許在某個平台上還未實現??
Time of Update: 2014-10-19
標籤:style blog http sp 2014 log bs line as Ruby的case運算式有兩種形式:第一種形式接近於一組連續的if語句:它讓你列出一組條件,並執行第一個為真的
Time of Update: 2014-12-13
ruby和linux shell共同編程的樣本,rubyshell 有了shell為毛還要ruby呢?話不能這麼說,有些小功能用ruby還是很方便的,比如說字串的反轉再加1功能用shell來寫就比較麻煩.str="123456",我們定義一個反轉後再+1的小方法:2.1.5 :020 > class String2.1.5 :021?> def r_add_12.1.5 :022?> replace