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

ruby 388

#Ruby
ruby 连接mysql

require "mysql" dbc = Mysql.real_connect('127.0.0.1','root','123','test') res = dbc.query(…

2015-03-11 1,009

#Ruby
rot13 加密算法

class String def rot13 self.tr "A-Za-z", "N-ZA-Mn-za-m" end end #用法 : print 'abcd'.rot13

2015-03-10 979

#Ruby
合数

def com(n) for i in 1..(n-1) if n%i==0 factor=i end end if factor>1 puts "The Number is…

2015-03-07 756

#Ruby
Ruby 提取 HTML 文档中的链接和图片

require 'rexml/document' require 'rexml/streamlistener' require 'set' class LinkGrabber in…

2015-03-07 210

#Ruby
Stream的Ruby实现

class Stream def initialize(head = nil, tail = nil) @head = head @tailFunc = tail end def …

2015-03-06 754

#Ruby
Ruby子类中返回覆盖方法的数组

class Object def self.overridden_methods(parent_class = Object, within_tree = true) if wit…

2015-03-06 503

#Ruby
使用Win32API操作鼠标

require 'Win32API' #定义API GetCursorPos和SetCursorPos的接口 get_cursor_pos = Win32API.new("user…

2015-03-04 995

#Ruby
win32 ruby 全局热键

#!/usr/bin/env ruby # -*- coding: gb18030 -*- # __FILE__ : hotkey.rb # 2012-7 # ruby 1.9 #…

2015-02-28 296

#Ruby
Defficient Number

def defficient(n) sumOfFactors=0 for i in 1..n if n%i==0 factor=i sumOfFactors += factor e…

2015-02-25 567

#Ruby
Hash转换为查询字符串

#依赖addressable/uri require 'addressable/uri' def _to_query_string(hash) if hash.instance_o…

2015-02-24 718

#Ruby
缺失的define_class

module Kernel def define_class(name, ancestor = Object) Object.const_set(name, Class.new(a…

2015-02-22 962

#Ruby
Rails 获取邮箱中所有邮件

require 'net/pop' mail_server = Net::POP3.new('mail.mailservernamehere.com')//连接 mail_serv…

2015-02-20 143
1 21 22 23 24 25 33