易截截图软件、单文件、免安装、纯绿色、仅160KB

Ruby 报表工具 Ruport

Ruport是一个免费的Ruby报表工具,它可以令到制作报表软件变得简单一些。Ruport支持从文件或者数据库获得数据,提供工具操作数据。额外地,Ruport支持高扩展的格式化软件,目前能够支援HTML、PDF、CSV和文本输出。
Ruport可能是Ruby目前唯一的报表工具,目前在持续开发中,更多的新特性正在添加。
安装方法:
gem install ruport -y
gem install ruport-util -y
示例代码:
require "rubygems"
require "ruport"
require "ruport/util"
class GraphReport < Ruport::Report
renders_as_graph
def renderable_data(format)
graph = Graph(%w[a b c d e])
graph.series [1,2,3,4,5], "foo"
graph.series [11,22,70,2,19], "bar"
return graph
end
end
GraphReport.generate do |r|
r.save_as("foo.svg", :template => :graph)
end
生成的图形:
http://www.open001.com/projectDetail_projectId_4297_channelId_5.html


相关文档:

ruby类变量在development模式失效

分页中用到类变量,主要是用来标记“页码输入框”的id 如果一个页面有几个分页,“页码输入框”的id要是不同的才能分清是哪个要分页。使用类变量就是为了达到这个目的,让所有的对象实例共用一个变量,不必每次重新初始化变量。 类变量使用代码示例 1 require 'ruby-debug'
2 debugger
3 cla ......

写的一个inter类模仿ruby整数的行为

我们知道ruby中对于整数的[],[]=,<<,>>操作是针对于二进制的值来运算的。
我现在写一个针对十进制数操作的类,拥有整数的所有方法,如下:
class InterEx
def initialize(val=0)
@val=val
end

def to_s
@val.to_s
end

def [](idx)
self.to_s[idx].to_i
end

d ......

ruby来枚举csdn未注册的用户名

require 'open-uri'
$NAME_CHARS= (?a..?z).to_a+(?0..?9).to_a
def is_name_used(name)
str=open('http://passport.csdn.net/UserExist.aspx?UserName='+name)
str=str.read
#str=str.encode('GBK','utf-8')
return true if str[/Red/]
end
def enum_names(len=2)
return if len<2
f=File.open(' ......

Use lambda in Ruby 九筒一条

http://www.robertsosinski.com/2008/12/21/understanding-ruby-blocks-procs-and-lambdas/
Understanding Ruby Blocks, Procs and Lambdas
Blocks, Procs and lambdas (referred to as closures
in Computer Science) are one of the most powerful aspects of Ruby, and
also one of the most misunderstood. This ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号