friendly class design


/ Published in: Ruby
Save to your folder(s)



Copy this code and paste it in your HTML
  1. def Table(*args,&block)
  2.  
  3. table = case args[0]
  4. when Array
  5. opts = args[1] || {}
  6. Ruport::Data::Table.new({:column_names => args[0]}.merge(opts),&block)
  7. when /\.csv$/i
  8. Ruport::Data::Table.load(*args,&block)
  9. when Hash
  10. if file = args[0].delete(:file)
  11. Ruport::Data::Table.load(file,args[0],&block)
  12. elsif string = args[0].delete(:string)
  13. Ruport::Data::Table.parse(string,args[0],&block)
  14. else
  15. Ruport::Data::Table.new(args[0],&block)
  16. end
  17. else
  18. end
  19. Ruport::Data::Table.new(:data => [], :column_names => args,&block)
  20. return table
  21. end

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.