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
Ïà¹ØÎĵµ£º
ÕâÊÇÒ»¸ö¿ªÔ´£¬Ãâ·Ñ£¬ÁéÇÉ£¬¼òÒ×µÄweb×Ô¶¯»¯²âÊÔ×éºÏ¿ò¼Ü£»Í¨³£Çé¿ö£¬¿ªÔ´µÄ¶«Î÷×ÜÊǸøÈËÒÔÃÔÈË£¬¿ª·ÅʽµÄ´¥¸Ð£¬µ«Í¬Ê±£¬Ò²ÈÃÈËÄÑÒÔ¿ìËÙ½Ó½ü£¨ÏñÊǶ«·½ÄÐÈË¿´´ýÎ÷·½ÃÀÅ®£©£»ÒªÁ˽âÒ»¸ö¿ªÔ´¶øÇÒ×éºÏƯÁÁµÄ¿ò¼Ü£¬×ÜÊÇÒª·ÑЩÖÜÕÂ......×ܶøÑÔÖ®£¬Ëü²»»áÏñÊշѵĶ«Î÷£¬ÄãºÜÌÖÑáËü£¬µ«²»¿É·ñÈÏ£¬ÄãµÄ¸¶·ÑÆäʵ»»È¡Á˱ðÈ˵ÄËöËéÀͶ ......
Ç°ÑÔ
ÔÚ¡¶RoutingµÄÔØÈë¡·ÖУ¬ÎÒ´óÖ½éÉÜÁËÒ»ÏÂRailsÖÐ×î¼òµ¥µÄrouteÊÇÈçºÎ¼ÓÔصġ£ÕâƪÎÄÕ£¬ÎÒ½«À´½²Ò»½²RailsϵͳÖиüΪ¸´ÔÓµÄnamed routeºÍÓëRESTfulÏà¹ØµÄresourceÊÇÈçºÎ±»¼ÓÔصġ£ÎªÁ˲»Öظ´Ì«¶àµÄ±ÊÄ«£¬ÕâƪÎÄÕ½«ÔÚÇ°ÎĵĻù´¡ÉϽøÐУ¬Èç¹û·¢ÏÖµ¥¶À¿´´ËÎÄʱ£¬ÓÐÉÙÐíÔÆÀïÎíÀ½¨ÒéÏÈ¿´Ò»¿´ÎÒµÄǰƪÎÄÕ£ºR ......
ruby³£¹æ·ÃÎÊaccessÊý¾Ý¿âµÄ·½·¨Ó¦¸ÃÊÇʹÓÃDBI¿â
£º
require 'dbi'
DBI.connect("DBI:ADO:Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db.mdb;")
¿ÉÊÇ
¼òµ¥³¢ÊÔÖ®ºóûÄܳɹ¦£¬ÌáʾÕÒ²»µ½Çý¶¯Æ÷ADO,ÀÁµÃÔÙÊÔ£¬ËìÕÒÆäËû·½·¨¡£
Ò»·¬ËÑË÷Ö®ºó£¬·¢ÏÖ¿ÉÒÔÓÃWIN32OLEÀ´·ÃÎÊaccess,дһ¸ö¼òµ¥µÄÀà°ü×°Ö®:
......
require 'curses'
module Curses
def self.program
main_scr=init_screen
noecho
cbreak
curs_set(0)
main_scr.keypad=true
yield main_scr
end
end
Curses.program do |scr|
max_x=scr.maxx
max_y=scr.maxy
100.times do
scr.setpos(rand(max_y),rand(max_x))
......
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 ......