Changeset 6348 for dan

Show
Ignore:
Timestamp:
02/07/08 21:02:07 (10 months ago)
Author:
akio0911
Message:

dan/ruby/akio0911/rails.rb add some lines

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • dan/ruby/akio0911/rails.rb

    r6294 r6348  
    314314p "admin/super_user".classify # "Admin::SuperUser" 
    315315=end 
     316 
     317=begin 
     318require 'rubygems' 
     319require 'active_support' 
     320p 1.second # 1 second 
     321p 2.minutes + 30.seconds # 150 seconds 
     322p 4.hours + 32.minutes # 16320 seconds 
     323p 10.months + 10.days # 10 months and 10 days 
     324p 1.week # 7 days 
     325p 1.fortnight # 14 days 
     326p 1.month # 1 month 
     327p 1.year # 1 year 
     328 
     329p Time.now # Thu Feb 07 15:16:29 +0900 2008 
     330p 10.minutes.ago # Thu Feb 07 15:06:45 +0900 2008 
     331p 20.minutes.from_now # Thu Feb 07 15:37:05 +0900 2008 
     332p 7.days.ago(Time.mktime(2006,1,1)) # Sun Dec 25 00:00:00 +0900 2005 
     333=end 
     334 
     335=begin 
     336require 'rubygems' 
     337require 'active_support' 
     338p 14.bytes # 14 
     339p 2.kilobytes # 2048 
     340p 256.megabytes # 268435456 
     341p 1.gigabytes # 1073741824 
     342p 1.gigabyte.class # Bignum 
     343p 2.terabytes # 2199023255552 
     344p 512.petabytes + 1.exabyte # 1729382256910270464 
     345=end 
     346 
     347=begin 
     348require 'rubygems' 
     349require 'active_support' 
     350p now = Time.mktime(2007, 6, 5, 4, 32) # Tue Jun 05 04:32:00 +0900 2007 
     351p (now + 3.days).midnight # Fri Jun 08 00:00:00 +0900 2007 
     352p now.next_month.beginning_of_month # Sun Jul 01 00:00:00 +0900 2007 
     353p now.end_of_month # Sat Jun 30 23:59:59 +0900 2007 
     354p Time.days_in_month(2, 2000) # 29 
     355p now.seconds_since_midnight # 16320.0 
     356p now.change(:year=>2005, :month=>6) # Sun Jun 05 04:32:00 +0900 2005 
     357p now.advance(:months=>-1, :days=>3) # Tue May 08 04:32:00 +0900 2007 
     358p now.months_ago(10) # Sat Aug 05 04:32:00 +0900 2006 
     359p now.last_year # Mon Jun 05 04:32:00 +0900 2006 
     360p now.next_year # Thu Jun 05 04:32:00 +0900 2008 
     361p now.last_month # Sat May 05 04:32:00 +0900 2007 
     362p now.next_month # Thu Jul 05 04:32:00 +0900 2007 
     363p now.beginning_of_week # Mon Jun 04 00:00:00 +0900 2007 
     364p now.next_week(:friday) # Fri Jun 15 00:00:00 +0900 2007 
     365p now.beginning_of_day # Tue Jun 05 00:00:00 +0900 2007 
     366p now.midnight # Tue Jun 05 00:00:00 +0900 2007 
     367p now.beginning_of_month # Fri Jun 01 00:00:00 +0900 2007 
     368p now.end_of_month # Sat Jun 30 23:59:59 +0900 2007 
     369p now.beginning_of_quarter # Sun Apr 01 00:00:00 +0900 2007 
     370p now.beginning_of_year # Mon Jan 01 00:00:00 +0900 2007 
     371p now.yesterday # Mon Jun 04 04:32:00 +0900 2007 
     372p now.tomorrow # Wed Jun 06 04:32:00 +0900 2007 
     373=end 
     374 
     375=begin 
     376class Symbol 
     377  def to_proc 
     378    Proc.new { |obj, *args| obj.send(self, *args) } 
     379  end 
     380end 
     381=end 
     382 
     383=begin 
     384array = [1,2,3] 
     385p array.map{ |i| i.to_s } # ["1", "2", "3"] 
     386=end 
     387 
     388=begin 
     389require 'rubygems' 
     390require 'active_support' 
     391array = [1,2,3] 
     392array.map(&:to_s) 
     393p array # [1, 2, 3] 
     394=end 
     395 
     396=begin 
     397require 'rubygems' 
     398require 'active_support' 
     399array = [1,2,3] 
     400block = :to_s 
     401p array.map(&block) 
     402=end 
     403 
     404=begin 
     405require 'rubygems' 
     406require 'active_support' 
     407array = [1,2,3] 
     408block = :to_s 
     409p array.map{ |obj| obj.send(:to_s)} 
     410=end 
     411 
     412=begin 
     413require 'rubygems' 
     414require 'active_support' 
     415array = [1,2,3] 
     416p array.map{ |obj| obj.to_s } 
     417=end 
     418 
     419=begin 
     420members = Member.find(:all) 
     421ids = members.map(&:id) 
     422names = members.map(&:name) 
     423=end