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

ruby 388

#Ruby
每3秒打印IP设置信息

loop do if PLATFORM =~ /linux/i puts `ifconfig ` else puts `ipconfig ` end sleep 3 p '-' *…

2015-05-24 674

#Ruby
根据路径递归创建不存在的文件夹

def my_mkdir(dirPath) unless File.exist?(dirPath) my_mkdir(dirPath[0, dirPath.rindex('/')]…

2015-05-23 363

#Ruby
从5a5x采集易语言源代码

# encoding: ASCII-8BIT require 'open-uri' def master title = ["系统工具","图形图像","多媒体类","游戏娱乐",…

2015-05-22 123

#Ruby
Ruby Excel 文件操作之添加 Sheet

require 'win32ole' excel = WIN32OLE.new("excel.application") excel['Visible'] = true workb…

2015-05-22 353

#Ruby
json解析代码生成器

# 一个类包含:类名,属性列表和内部类指针 class Clazz def initialize(cls_name) @cls_name = cls_name @attrs=[] …

2015-05-21 845

#Ruby
闰年

def leap? year (year%4 == 0) and !(year%100 == 0 and year%400 != 0) end puts leap? 1978 # …

2015-05-21 147

#Ruby
常用基础备忘

#coding:utf-8 #熟悉ruby基本数据类型 class Ruby01 puts "基本数字类型" puts 1 puts 1.0 puts 1.class #输出Fix…

2015-05-20 690

#Ruby
Ruby 往压缩包中添加新文件

require 'zlib' file = 'compressed.gz' Zlib::GzipWriter.open(file) do |gzip| gzip << …

2015-05-19 554

#Ruby
Ruby 之 RSS 2.0 解析

require 'rss/2.0' require 'open-uri' url = 'http://www.oschina.net/code/rss' feed = RSS::P…

2015-05-17 338

#Ruby
访问 Mongrel 时(http://localhost:1234) 返回简单页面

require 'rubygems' require 'mongrel' class BasicServer < Mongrel::HttpHandler def proce…

2015-05-15 600

#Ruby
复杂的Ruby web service

require 'socket' server = TCPServer.open(2000) # Listen on port 2000 sockets = [server] # …

2015-05-15 371

#Ruby
Ruby 实现表格方式的布局管理

require 'tk' root = TkRoot.new 3.times { |r| 4.times { |c| TkLabel.new(root) { text "row #…

2015-05-15 393
1 15 16 17 18 19 33