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

ruby 388

#Ruby
Ruby 使用 FTP 上传文件

require 'net/ftp' ftp = Net::FTP.new('ftp.domain.com') ftp.passive = true ftp.login ftp.ch…

2014-11-05 925

#Ruby
Ruby万能数组(包括数组,队列,栈,哈希)

#万能数组 class AllArray def initialize(type) if type=="array" @items=[] def add(element) @ite…

2014-11-03 780

#Ruby
版本比较

# * 版本比较 # * @param version1 # * @param version2 # * @return # * -1: version1小于version2 # …

2014-11-02 600

#Ruby
ruby操作cassandra数据库

# encoding:utf-8 require 'rubygems' require 'cassandra/1.0' # 建立数据库连接 cdb = Cassandra.new(…

2014-11-02 167

#Ruby
角度弧度转换代码

def d2r() puts "Enter the value of angle in degree" t=gets.chomp.to_f #corresponding value…

2014-10-30 897

#Ruby
Ruby 使用 Net::Ping 连接到指定的 TCP/UDP 端口

require 'rubygems' require 'net/ping' if Net::PingTCP.new('http://www.google.com/', 80).pi…

2014-10-29 401

#Ruby
Ruby创建QR码

require 'rubygems' require 'rqrcode' require 'qr_image' # QR Code parameters text = 'This …

2014-10-28 988

#Ruby
Ruby 使用 DRb 启动远程对象服务

require "drb" require "drb_observer" class Ticker include DRbObservable def initialize() T…

2014-10-26 281

#Ruby
Ruby 编写一个 SOAP 服务器端

require 'soap/rpc/standaloneServer' class MyServer < SOAP::RPC::StandaloneServer def in…

2014-10-23 697

#Ruby
ruby读取http文件保存到本地

require 'open-uri' File.open('/home/user/1.jpg', 'wb') {|f| f.write(open('http://tp1.sinai…

2014-10-23 327

#Ruby
Ruby 调用 Windows Excel 来生成电子表格

require 'win32ole' excelobj = WIN32OLE.new("excel.application") excelobj['Visible']=TRUE e…

2014-10-22 760

#Ruby
Ruby 检查 HTTP 回应的错误和重定向

require 'net/http' def get_web_document(url) uri = URI.parse(url) response = Net::HTTP.get…

2014-10-22 515