ActiveSupport


FrontPage

ActiveSupport::CoreExtensions?

Array

  • to_param
    配列を、スラッシュ(/) で区切られた文字列に変換します。
    ただ、内部的に join しているだけ。
    ['dir1', 'dir2', 'file'].to_param
    => "dir1/dir2/file"
  • to_sentence(options = {})
    配列を、カンマで区切られた文に変換し、
    最後の要素は、:connector によって指定された単語で結合します。
    ['test', 'file1', 'file2'].to_sentence(:connector => 'and')
    => "test, file1, and file2"
    options
    • :connector
      最後の要素を結合するとき、:connectorに指定した要素が使われます。
      デフォルトは、'and' です。
    • :skip_last_comma trueにすると、最後の要素を結合するときに、カンマを出力しなくなります。
      たとえば、"a, b, and c" が、 "a, b and c" となります。
  • to_xml(options = {})

Date

様々の便利な文字列表現や
その他のオブジェクトから "日付" を得ます。

"2005/12/24 11:00:00".to_date.to_s
=> "2005-12-24"
Time.now.next_month.to_date.to_s
=> "2006-07-04"
  • to_date()
    Dates と、Times を維持する事が出来るように変換する。
  • to_formatted_s(format = \:default)
    Time.now.to_formatted_s(:short)
    => "04 Jun 19:56"
    
    Time.now.to_formatted_s(:long)
    => "June 04, 2006 19:56"
  • to_time(form = :local)

Integer

  • 奇数であるか偶数であるか調べます。
    1.even? # => false
    1.odd? # => true
    2.even? # => true
    2.odd? # => false
  • 指定された数で割り切れるか調べます。
    10.multiple_of?(2) # => true
  • ordinalize()
    1.ordinalize # => "1st"
    3.ordinalize # => "3rd"
    10.ordinalize # => "10th"
  • byte値
    • byte
    • bytes
    • exabyte
    • exabytes
    • gigabyte
    • gigabytes
    • kilobyte
    • kilobytes
    • megabyte
    • megabytes
    • petabyte
    • petabytes
    • terabyte
    • terabytes
      1.gigabyte # => 1073741824

最新の20件

2006-08-16 2006-07-20 2006-06-11 2006-06-04
  • ActiveSupport
2006-06-03

  • counter: 624
  • today: 1
  • yesterday: 0
  • online: 1