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

ruby 388

#Ruby
Hello world 之 wxRuby 版

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

2015-06-02 193

#Ruby
简单的ruby web service with socket

require 'socket' # Get sockets from stdlib server = TCPServer.open(2000) # Socket to liste…

2015-06-01 126

#Ruby
Ruby 简单的 UDP 程序示例

require 'socket' host = 'localhost' port = 1234 s = UDPSocket.new s.bind(nil, port) s.send…

2015-06-01 913

#Ruby
Ruby 版的 PinkTrace 示例 pink-simple-strace-linux.rb

#!/usr/bin/env ruby # coding: utf-8 # vim: set sw=2 sts=2 et nowrap fenc=utf-8 : require '…

2015-05-31 169

#Ruby
Ruby 的 YAML 对象序列化

require 'yaml' class Special def initialize(valuable, volatile, precious) @valuable = valu…

2015-05-31 933

#Ruby
Ruby 获取 HTTP 回应中的所有 Head 信息

require 'uri' Net::HTTP.get(URI.parse("http://www.oschina.net")) response = Net::HTTP.get_…

2015-05-30 270

#Ruby
距离换算器

print "Enter an amount: " amount = gets.to_f print "Convert it from what(inches, feet, mil…

2015-05-29 256

#Ruby
华氏到摄氏的转换

#PennyBoki @ </dream.in.code> puts "Please select " puts 'A for Celsius to Fahrenhei…

2015-05-29 361

#Ruby
正则表达式 Ruby中创建URL排列

# return 4 urls, with and without trailing slash, with and without www # useful for matchi…

2015-05-28 186

#Ruby
Ruby 的 UDP 服务器简单一例

require 'socket' s = UDPSocket.new s.bind(nil, 1234) 5.times do text, sender = s.recvfrom(…

2015-05-28 985

#Ruby
Array#join

data = [’1′, ‘2′, ‘3′] s = ‘ ‘ data.each { |x| s << x << ‘ and a ‘ } s # =>…

2015-05-28 912

#Ruby
Ruby 使用 DRb 调用远程对象方法

require 'drb' class TestServer def add(*args) args.inject {|n,v| n + v} end end server = T…

2015-05-28 912
1 14 15 16 17 18 33