首页 软件开发 代码片段 ruby ( Page 15 )

ruby 388

#Ruby
Ruby 设置主窗体大小(TK)

#!/usr/bin/env ruby require 'tk' TkRoot.new {title "Ruby is fun!" } TkLabel.new { font TkF…

2015-06-12 732

#Ruby
Ruby计算加权平均分(基于Hash)

@items=Hash.new puts "please input the number of your courses:" course_number=gets puts "p…

2015-06-11 158

#Ruby
淘宝网防盗链图片批量下载

# == Synopsis # # Taobao tool all in one. # # == Author # fujun # 2011.06.01 # # == Copyri…

2015-06-09 994

#Ruby
Ruby按规律求第15个数是多少(答案是377)

def method n a, b = 0, 1 (n-2).times {a, b = b, a + b} puts b end method 15

2015-06-07 412

#Ruby
Hpricot 获取HTML文档中某个元素第一次出现的位置

require 'rubygems' require 'hpricot' require 'open-uri' doc = Hpricot(open('http://www.rub…

2015-06-06 942

#Ruby
Ruby版“Ruby太慢了”问题

class Integer def reverse(a = 0) n = self while n > 0 a = a * 10 + n % 10 n /= 10 end r…

2015-06-05 862

#Ruby
遍历文件夹下所有文件,输出文件名

def traverse_dir(file_path) if File.directory? file_path Dir.foreach(file_path) do |file| …

2015-06-05 993

#Ruby
分组数据项的平均数

puts "Enter Number Of Classes" n=gets.chomp n=n.to_i puts "Enter Class Interval" h=gets.ch…

2015-06-04 469

#Ruby
Ruby 读写 YAML 配置文件

require 'yaml' configuration = { 'color' => 'blue', 'font' => 'new romain', 'font-si…

2015-06-03 716

#Ruby
Ruby mergesort 归并排序

def merge_sort(a, b) if a.length > 1 temArr = split_array(a) a = merge_sort(temArr[0], …

2015-06-03 779

#Ruby
Hello world 之 wxRuby 版

require "wx" include Wx # a new class which derives from the Wx::App class class HelloWorl…

2015-06-02 193
1 13 14 15 16 17 33