大家應該都知道我又重新入手了Macbook
實在是忘不了那種感覺啊!
而且XCode + Interface Builder根本就是絕配!!
用Ruby寫OSX程式也不會覺得討厭,所以..
hechian 發表在 痞客邦 留言(0) 人氣(250)
感謝在Ruby-talk上的:
Chris Carter
David A. Black
Harry
Robert Dober
James Edward
hechian 發表在 痞客邦 留言(0) 人氣(360)
這是http://www.ruby-lang.org/zh_TW/ 站長所寫的一篇教學
網址是:http://info.sayya.org/~sjh/sjh_rubygtk.pdf
寫得很詳細、簡單明瞭!
如果有需要可以看看
hechian 發表在 痞客邦 留言(0) 人氣(766)
XML文件我是用ReXML啦.. 不過我這邊不是要介紹ReXML,是要來介紹hpricot這個Library的
安裝方式:
gem install hpricot
or
gem install hpricot --source http://code.whytheluckystiff.net
hechian 發表在 痞客邦 留言(0) 人氣(207)
在Ruby中,File可以用readlines跟跑while迴圈來讀
在這個例子中,程式p1用的是while迴圈,p2用的是readlines
執行後,秒數分別是
P1:
121.468秒
hechian 發表在 痞客邦 留言(0) 人氣(184)
Gyre是一個網頁版的Rails Editor,雖然是網頁版的可是別小看它喔!
它的執行環境不過就只是從Desktop換到Web而已,一般IDE該有的功能都有喔!
Ruby Inside上有介紹:http://www.rubyinside.com/gyre-web-based-ide-and-debugger-for-rails-383.html
官方網站:http://gyre.bitscribe.net/
hechian 發表在 痞客邦 留言(0) 人氣(350)
require 'Win32API'
=begin
Message Box:
Coded by CFC <at> Zuso Security
CFC <zusocfc@gmail.com>
hechian 發表在 痞客邦 留言(0) 人氣(420)
研究了一下.. 寫出來當Memo..
我先以一個簡單的例子來解說,就用大家最愛的MessageBox吧!
require 'win32api'
msgbox = Win32API.new('user32', 'MessageBox', %w(p p p i), 'i')
msgbox.call(0, "Message body", "Messagebox title", 1) # hwnd, lpText, lpCaption, wType => Come from API Viewer (API檢視員)
hechian 發表在 痞客邦 留言(0) 人氣(554)
這是我自己寫的Ruby教學..
希望各位前輩們不吝指教!
也歡迎新朋友們參考討論:)
網址是:
http://zusocfc.pbwiki.com/Ruby%E6%95%99%E5%AD%B8%E7%B3%BB%E5%88%97
hechian 發表在 痞客邦 留言(0) 人氣(1,866)
搭配物件導向@@
觀看可讀性高的原始碼請按此
class Stack
def initialize ary=0, max=0, lvl=0
@ary = ary
@max = max
@lvl = lvl
end
def add
if @lvl < @max
puts "Please input a value for add to the stack!"
@ary[@lvl] = self.get_value
@lvl+=1
puts "Now you have #{@lvl} elements for the array!"
else
puts "Stack is full!"
end
end
def del
puts "#{@ary[@lvl-1]} has been removed!"
@lvl -= 1
if @lvl <= 0
puts "You have no element in the array!"
else
puts "Now you have #{@lvl} elements in the array!"
end
end
def get_value
return gets.chomp
end
def list
if @lvl <= 0
puts "You have no element in the array!"
else
for ele in 0 ... @lvl
puts @ary[ele]
end
end
true
end
public :initialize, :add, :del, :list
protected :get_value
end
puts "Please input a number for the stack max!"
ary = {}
max = gets.chomp.to_i
lvl = 0
stack = Stack.new(ary, max, lvl)
=begin
Actions:
1. add -- for add elements
2. del -- for remove elements
3. list -- for list elements
4. exit -- end this program
=end
while true
puts "Please select a action!"
puts <Actions:
1. add -- for add elements
2. del -- for remove elements
3. list -- for list elements
4. exit -- end this program
EOF
action = gets.chomp
case action
when "add" ,"1"
puts "Adding array element!"
stack.add
when "del", "2"
puts "Removing array element!"
stack.del
when "list", "3"
puts "Listing array elements!"
stack.list
when "exit", "4"
puts "Bye~ bye!"
exit
end
end
hechian 發表在 痞客邦 留言(0) 人氣(167)