{"id":133,"date":"2014-10-14T18:50:03","date_gmt":"2014-10-14T09:50:03","guid":{"rendered":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2014\/10\/14\/active-support"},"modified":"2014-10-14T18:50:03","modified_gmt":"2014-10-14T09:50:03","slug":"active-support","status":"publish","type":"post","link":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2014\/10\/14\/active-support\/","title":{"rendered":"\u79cb\u306e\u591c\u9577\u306bActive Support"},"content":{"rendered":"

Rails\u306eActive Support\u306e\u30bd\u30fc\u30b9\u306f\u6bd4\u8f03\u7684\u8aad\u307f\u3084\u3059\u3044\u3082\u306e\u304c\u591a\u304f\u3001\u304a\u5f79\u7acb\u3061\u30e1\u30bd\u30c3\u30c9\u3082\u3044\u308d\u3044\u308d\u3068\u3042\u308b\u306e\u3067\u3001\u6700\u8fd1\u9152\u306e\u3064\u307e\u307f\u4ee3\u308f\u308a\u306b\u591c\u306a\u591c\u306a\u8aad\u307f\u59cb\u3081\u305f\u4e0b\u689d\u3067\u3059\u3002<\/p>\n

\u7279\u306b\u3001Ruby\u306e\u7d44\u307f\u8fbc\u307f\u30af\u30e9\u30b9\u3092\u62e1\u5f35\u3059\u308bCore Extensions\u306e\u30bd\u30fc\u30b9\u3092\u8aad\u3093\u3067\u3044\u308b\u3068\u3001\u77e5\u3089\u306a\u304b\u3063\u305f\u304a\u5f79\u7acb\u3061\u30e1\u30bd\u30c3\u30c9\u304c\u3042\u3063\u305f\u308a\u3001\u3053\u3093\u306a\u3082\u306e\u4f7f\u3046\u3093\u304b\u3044\u306a\u3063\u3066\u30e1\u30bd\u30c3\u30c9\u3082\u3051\u3063\u3053\u3046\u3042\u3063\u305f\u308a\u3067\u304a\u3082\u3057\u308d\u3044\u3002\u5b9f\u969b\u3001\u975e\u5e38\u306b\u5f79\u306b\u7acb\u3064\u30e1\u30bd\u30c3\u30c9\u3082\u3042\u308b\u3002Object#try\u306a\u3069\u3002
\n\u30ac\u30a4\u30c9<\/a>\u306b\u307e\u3068\u307e\u3063\u3066\u3044\u308b\u306e\u3060\u304c\u3001\u5168\u90e8\u306e\u6a5f\u80fd\u304c\u66f8\u3044\u3066\u3042\u308b\u308f\u3051\u3067\u306f\u306a\u3044\u306e\u3067\u3001\u30bd\u30fc\u30b9\u3092\u8aad\u3093\u3067\u307f\u308b\u306e\u3082\u30aa\u30c4\u306a\u3082\u306e\u3067\u3042\u308b\u3002\u4eca\u56de\u306f\u3001\u3056\u3063\u3068\u76ee\u306b\u7559\u307e\u3063\u305f\u3082\u306e\u3092\u3068\u308a\u3068\u3081\u306a\u304f\u7d39\u4ecb\u3055\u305b\u3066\u3044\u305f\u3060\u304d\u305f\u3044\u3068\u601d\u3046\u3002<\/p>\n

String\u30af\u30e9\u30b9<\/h2>\n

String\u30af\u30e9\u30b9\u306e\u62e1\u5f35\u3002\u6587\u5b57\u5217\u64cd\u4f5c\u306f\u6982\u3057\u3066\u6c5a\u3044\u30b3\u30fc\u30c9\u306b\u306a\u308a\u304c\u3061\u3060\u304c\u3001\u3053\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3046\u3068\u7c21\u5358\u306b\u66f8\u3051\u308b\u5834\u5408\u304c\u3042\u308b\u3002<\/p>\n

rails\/activesupport\/lib\/active_support\/core_ext\/string\/access.rb<\/h3>\n

String#at<\/h4>\n
'hello'.at(0) # => "h"\n'hello'.at(1..3) # => "ell"\n'hello'.at(\/lo\/) # => "lo"\n'hello'.at(\/ol\/) # => nil<\/code><\/pre>\n

\u6307\u5b9a\u7b87\u6240\u306e\u6587\u5b57\u5217\u3092\u53d6\u5f97\u3059\u308b\u4ee5\u5916\u306b\u3082\u3001\u6b63\u898f\u8868\u73fe\u3092\u6307\u5b9a\u3059\u308b\u3068\u30de\u30c3\u30c1\u3057\u306a\u304b\u3063\u305f\u3089nil\u304c\u8fd4\u308b\u3053\u3068\u3092\u5229\u7528\u3057\u3066\u3001\u6587\u5b57\u5217\u306e\u5b58\u5728\u30c1\u30a7\u30c3\u30af\u306b\u4f7f\u3046\u3053\u3068\u3082\u53ef\u80fd\u3002<\/p>\n

String#from, String#to<\/h4>\n
'hello'.from(1).to(-2) # => "ell"<\/code><\/pre>\n

from\u3068to\u3092\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001\u59cb\u3081\u304b\u30892\u6587\u5b57\u76ee\u304b\u3089\u3001\u7d42\u308f\u308a\u304b\u30892\u6587\u5b57\u76ee\u3092\u3068\u308b\u3068\u3044\u3063\u305f\u3053\u3068\u304c\u304d\u308c\u3044\u306b\u66f8\u3051\u308b\u3002<\/p>\n

rails\/activesupport\/lib\/active_support\/core_ext\/string\/conversions.rb<\/h3>\n

String#to_time<\/h4>\n
"13-12-2012".to_time               # => 2012-12-13 00:00:00 +0900\n"06:12".to_time                    # => 2014-10-14 06:12:00 +0900\n"2012-12-13 06:12".to_time         # => 2012-12-13 06:12:00 +0900\n"2012-12-13T06:12".to_time         # => 2012-12-13 06:12:00 +0000\n"2012-12-13T06:12".to_time(:utc)   # => 2012-12-13 06:12:00 UTC<\/code><\/pre>\n

\u3044\u308d\u3044\u308d\u306a\u5f62\u5f0f\u306e\u6587\u5b57\u5217\u3092\u3088\u308d\u3057\u304fTime\u578b\u306b\u5909\u63db\u3057\u3066\u304f\u308c\u308b\u306e\u3067\u3001\u6587\u5b57\u5217\u3092Time\u578b\u306b\u5909\u63db\u3057\u305f\u304f\u306a\u3063\u305f\u3068\u304d\u306b\u306f\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u304c\u4f7f\u3048\u308b\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u306e\u304c\u3088\u3044\u3068\u601d\u3046\u3002
\n\u307e\u305f\u3001Time\u578b\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u30e1\u30bd\u30c3\u30c9\uff08to_formatted_s\uff09\u3068\u7d44\u307f\u5408\u308f\u305b\u308b\u3068\u3001<\/p>\n

"13-12-2012".to_time(:utc).to_formatted_s(:iso8601) # => "2012-12-13T00:00:00Z"<\/code><\/pre>\n

\u3053\u306e\u3088\u3046\u306b\u3001ISO8601\u5f62\u5f0f\u306e\u6587\u5b57\u5217\u306b\u3067\u304d\u305f\u308a\u3059\u308b\u306e\u3067\u3001API\u306a\u3069\u3067\u65e5\u6642\u60c5\u5831\u3092\u8fd4\u3059\u3068\u304d\u306a\u3069\u4f7f\u3048\u305d\u3046\u3067\u3042\u308b\u3002<\/p>\n

\u540c\u69d8\u306bDate\u578b\u3084DateTime\u578b\u3078\u306e\u5909\u63db\u3082\u53ef\u80fd\u3002<\/p>\n

"1-1-2012".to_date # => Sun, 01 Jan 2012\n"1-1-2012".to_datetime # => Sun, 01 Jan 2012 00:00:00 +0000<\/code><\/pre>\n

rails\/activesupport\/lib\/active_support\/core_ext\/string\/filters.rb<\/h3>\n

String#remove<\/h4>\n
"hoge\r\nhoge".remove!(\/\r|\r\n|\n\/) # => "hogehoge"<\/code><\/pre>\n

\u6b63\u898f\u8868\u73fe\u3067\u30de\u30c3\u30c1\u3057\u305f\u6587\u5b57\u5217\u3092\u53d6\u308a\u9664\u304f\u3002
\n\u4e0a\u8a18\u4f8b\u306f\u6539\u884c\u30b3\u30fc\u30c9\u3092\u53d6\u308a\u9664\u304f\u30b3\u30fc\u30c9\u3002str.gsub!(\/
\n|
\n|
\n\/, '')\u3088\u308a\u3082\u3061\u3087\u3063\u3068\u304d\u308c\u3044\u3002<\/p>\n

'Once upon a time in a world far far away'.truncate(27) # => "Once upon a time in a wo..."\n'Once upon a time in a world far far away'.truncate(27, separator: ' ') # => "Once upon a time in a..."\n'\u3080\u304b\u3057\u3080\u304b\u3057\u3042\u308b\u3068\u3053\u308d\u306b\u304a\u3058\u3044\u3055\u3093\u3068'.truncate(15, omission: '\u3002\u3002\u3002') # => "\u3080\u304b\u3057\u3080\u304b\u3057\u3042\u308b\u3068\u3053\u308d\u306b\u3002\u3002\u3002"<\/code><\/pre>\n

\u6587\u5b57\u5217\u3092\u5207\u308a\u53d6\u3063\u3066\u3001\u6700\u5f8c\u306b'...'\u3092\u4ed8\u52a0\u3059\u308b\u3002\u30bb\u30d1\u30ec\u30fc\u30bf\u3092\u6307\u5b9a\u3059\u308b\u3068\u3001\u5358\u8a9e\u306e\u533a\u5207\u308a\u307e\u3067\u3067\u5207\u3063\u3066\u304f\u308c\u308b\u3002\u307e\u305f\u3001\u6700\u5f8c\u306b\u4ed8\u52a0\u3059\u308b\u6587\u5b57\u5217\uff08omission\uff09\u3082\u5909\u66f4\u53ef\u80fd\u3067\u3042\u308b\u3002\u3051\u3063\u3053\u3046\u4f7f\u3048\u308b\u5834\u9762\u306f\u3042\u308b\u304b\u3082\u3057\u308c\u306a\u3044\u3068\u601d\u3046\u3002\u6614\u3001Twitter\u6295\u7a3f\u7528\u306b\u6587\u5b57\u5217\u3092'...'\u7d42\u7aef\u306e140\u6587\u5b57\u306b\u5207\u308a\u8a70\u3081\u308b\u51e6\u7406\u3092\u66f8\u3044\u305f\u3053\u3068\u304c\u3042\u308b\u306e\u3060\u304c\u3001\u3053\u308c\u3092\u77e5\u3063\u3066\u3044\u308c\u3070\u4e00\u77ac\u3067\u66f8\u3051\u305f\u3068\u3053\u308d\u3067\u3042\u308b\u3002<\/p>\n

'Once<br>upon<br>a<br>time<br>in<br>a<br>world'.truncate_words(5, separator: '<br>')   #=> "Once<br>upon<br>a<br>time<br>in..."<\/code><\/pre>\n

4.2\u3067\u8ffd\u52a0\u3055\u308c\u308b\u30e1\u30bd\u30c3\u30c9\u3002\u30bb\u30d1\u30ec\u30fc\u30bf\u3067\u5358\u8a9e\u3054\u3068\u306b\u533a\u5207\u3063\u3066\u6307\u5b9a\u306e\u6570\u307e\u3067\u3092\u8fd4\u3059\u3002\u4f7f\u3046\u6a5f\u4f1a\u306f\u3042\u308b\u304b\u306a\u3002\u3002\u3002<\/p>\n

rails\/activesupport\/lib\/active_support\/core_ext\/string\/inflections.rb<\/h3>\n

Rails\u3063\u307d\u3044\u91cd\u8981\u306a\u30e1\u30bd\u30c3\u30c9\u304c\u3044\u308d\u3044\u308d\u5165\u3063\u3066\u3044\u308b\u30bd\u30fc\u30b9\u3002\u5358\u6570\u8907\u6570\u3092\u5909\u63db\u3059\u308b\u30e1\u30bd\u30c3\u30c9puluralize, singularize, \u5916\u90e8\u30ad\u30fc\u540d\u3092\u751f\u6210\u3059\u308bforeign_key, Camel Case\u306b\u5909\u63db\u3059\u308bcamelize\u306a\u3069\u306a\u3069\u3002<\/p>\n

String#pluralize, String#singularize<\/h4>\n
'car'.pluralize # => "cars"\n'person'.pluralize # => "people"\n'people'.singularize # => "person"<\/code><\/pre>\n

\u5358\u8a9e\u3092\u8907\u6570\u5f62\u306b\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u3068\u3001\u305d\u306e\u9006\u306e\u30e1\u30bd\u30c3\u30c9\u3002\u30ac\u30a4\u30c9\u306b\u3082\u66f8\u3044\u3066\u3042\u308b\u901a\u308a\u3001Active Record\u3067\u306fpluralize\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u3001\u30e2\u30c7\u30eb\u306b\u5bfe\u5fdc\u3059\u308b\u30c6\u30fc\u30d6\u30eb\u540d\u3092\u53d6\u5f97\u3057\u3066\u3044\u308b\u3002<\/p>\n

\u306a\u304a\u3001\u3053\u3053\u306e\u5909\u63db\u30eb\u30fc\u30eb\u306f\u96e3\u3057\u305d\u3046\u306b\u601d\u3048\u308b\u3051\u308c\u3069\u3082\u610f\u5916\u3068\u30b7\u30f3\u30d7\u30eb\u3067\u3001\u4ee5\u4e0b\u306e\u30bd\u30fc\u30b9\u306b\u66f8\u3044\u3066\u3042\u308b\u3002
\nhttps:\/\/github.com\/rails\/rails\/blob\/master\/activesupport\/lib\/active_support\/inflections.rb<\/a><\/p>\n

\u305f\u3060\u3001\u5fae\u5999\u306a\u5909\u63db\u304c\u3055\u308c\u308b\u3053\u3068\u304c\u3042\u308b\u3088\u3046\u3067\u3001\u4f8b\u3048\u3070\u3053\u306ePull Request<\/a>\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u304a\u304b\u3057\u306a\u5909\u63db\u3092\u4fee\u6b63\u3059\u308b\u3082\u306e\u3067\u3042\u308b\u3002<\/p>\n

'waves'.singularize # => 'wafe' \u203b\u672c\u6765\u306f'wave'\u304c\u8fd4\u308b\u3079\u304d\uff01<\/code><\/pre>\n

\u3057\u304b\u3057\u3001\u3053\u306ePull Request\u306f\u30de\u30fc\u30b8\u3055\u308c\u3066\u3044\u306a\u3044\u3002\u3068\u3044\u3046\u306e\u3082\u3001Inflector\u306e\u5358\u6570\u8907\u6570\u5909\u63db\u306e\u30b3\u30a2\u30eb\u30fc\u30eb\u3092\u5909\u3048\u3066\u3057\u307e\u3046\u3068\u65e2\u5b58\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3078\u306e\u5f71\u97ff\u304c\u5927\u304d\u3044\u305f\u3081\u306b\u3001\u5358\u6570\u8907\u6570\u5909\u63db\u306e\u30eb\u30fc\u30eb\u306f\u51cd\u7d50\u3055\u308c\u3066\u3044\u308b\u305f\u3081\u3067\u3042\u308b\u3002\u305d\u306e\u305f\u3081\u3001\u5fc5\u8981\u306a\u5834\u5408\u306b\u306f\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3054\u3068\u306b\u30ab\u30b9\u30bf\u30e0\u30eb\u30fc\u30eb\u3067\u5909\u66f4\u3057\u3066\u304f\u308c\u3068\u306e\u3053\u3068\u3067\u3042\u308b\u3002\u8abf\u3079\u3066\u307f\u308b\u3068\u4ed6\u306b\u3082\u540c\u69d8\u306b\u30eb\u30fc\u30eb\u3092\u4fee\u6b63\u3059\u308bPull Request\u304c\u4f55\u500b\u3082\u3042\u3063\u305f\u3002\uff08\u5168\u3066\u30de\u30fc\u30b8\u3055\u308c\u305a\u306b\u30af\u30ed\u30fc\u30ba\u3002\uff09<\/p>\n

https:\/\/github.com\/rails\/rails\/pull\/17134<\/a>
https:\/\/github.com\/rails\/rails\/pull\/15740<\/a>
https:\/\/github.com\/rails\/rails\/pull\/13065<\/a>
https:\/\/github.com\/rails\/rails\/pull\/10812<\/a> <\/p>\n

\u73fe\u5728\u306e\u30bd\u30fc\u30b9\u3067\u306f\u3001\u300c\u3053\u306e\u5909\u63db\u30eb\u30fc\u30eb\u306f\u5b8c\u5168\u306a\u3082\u306e\u3067\u306a\u3044\u304c\u3001\u65e2\u5b58\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3078\u306e\u5f71\u97ff\u3092\u907f\u3051\u308b\u305f\u3081\u306b\u4fee\u6b63\u3059\u308b\u3053\u3068\u306f\u306a\u3044\u300d\u3053\u3068\u304c\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30b3\u30e1\u30f3\u30c8\u3067\u8a18\u8f09\u3055\u308c\u3066\u3044\u308b\u3002
\n
https:\/\/github.com\/rails\/rails\/commit\/07c70245a128cfe42f134be8759963dc98f1a63e<\/a><\/p>\n

# Define the standard inflection rules. These define a starting point for\n# new projects and are not considered complete. The current set of inflection\n# rules is frozen. This means, we do not change them to become more complete.\n# This is a safety measure to keep existing applications from breaking.<\/code><\/pre>\n

\u307e\u3042\u3001\u3044\u305a\u308c\u306b\u305b\u3088\u3001\u958b\u767a\u8005\u3068\u3057\u3066\u306f\u3001\u4e0d\u81ea\u7136\u306a\u5909\u63db\u304c\u3055\u308c\u308b\u5834\u5408\u304c\u3042\u308b\u3068\u3044\u3046\u3068\u3053\u308d\u3092\u610f\u8b58\u3057\u3066\u304a\u3051\u3070\u3088\u3044\u3068\u304a\u3082\u3046\u3002<\/p>\n

Numeric\u30af\u30e9\u30b9<\/h2>\n

rails\/activesupport\/lib\/active_support\/core_ext\/numeric\/bytes.rb<\/h3>\n

Numeric#byte, Numeric#kilobyte, ...<\/h4>\n
1.byte                    # => 1\n2.kilobytes               # => 2048\n45.bytes + 2.6.megabytes  # => 2726342.6<\/code><\/pre>\n

\u6700\u5f8c\u306e\u4f8b\u306f\u30bd\u30fc\u30b9\u306e\u30b3\u30e1\u30f3\u30c8\u306b\u66f8\u3044\u3066\u3042\u308b\u4f8b\u3002
\u306a\u304a\u30011kilobyte = 1024 * 1byte\u3067\u3042\u308b\u3002<\/p>\n

rails\/activesupport\/lib\/active_support\/core_ext\/numeric\/conversions.rb<\/h3>\n

\u96fb\u8a71\u756a\u53f7\u3001\u901a\u8ca8\u3001\u30d1\u30fc\u30bb\u30f3\u30c6\u30fc\u30b8\u306a\u3069\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3092\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u304c\u5165\u3063\u3066\u3044\u308b\u3002\u4f8b\u3048\u3070\u3001<\/p>\n

1235551234.to_s(:phone, area_code: true) # => "(123) 555-1234"<\/code><\/pre>\n

\u96fb\u8a71\u756a\u53f7\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3002\u3057\u304b\u3057\u3001Numeric\u30af\u30e9\u30b9\u306e\u30e1\u30bd\u30c3\u30c9\u306a\u306e\u3067\u3001\u96fb\u8a71\u756a\u53f7\u306b\u3064\u3044\u3066\u3044\u3048\u3070\u3001\u5f53\u7136\u306a\u304c\u3089\u5148\u982d\u304c\u30bc\u30ed\u3060\u3068\u4f7f\u3048\u306a\u3044\u3002\u65e5\u672c\u306b\u9650\u3089\u305a\u96fb\u8a71\u756a\u53f7\u304c\u30bc\u30ed\u304b\u3089\u59cb\u307e\u308b\u30d1\u30bf\u30fc\u30f3\u306f\u591a\u3044\u306e\u3067\u3001\u3042\u307e\u308a\u4f7f\u3048\u306a\u3044\u304b\u3082\u3057\u308c\u306a\u3044\u3002<\/p>\n

1234567890.5.to_s(:currency, locale: :ja) # => "1,234,567,891\u5186"\n1234567890.4.to_s(:currency, locale: :ja) # => "1,234,567,890\u5186"\n1234567890.4.to_s(:currency, locale: :ja, delimiter: '') # => "1234567890\u5186"<\/code><\/pre>\n

\u901a\u8ca8\u306e\u5f62\u5f0f\u306b\u5909\u63db\u3002<\/p>\n

\u4ed6\u306b\u3082\u3001\u4f8b\u3048\u3070<\/p>\n

12345.to_s(:human, locale: :en) # => "12.3 Thousand"\n12345.to_s(:human) # => "12.3 \u5343"<\/code><\/pre>\n

\u65e5\u672c\u8a9e\u306e\u5834\u5408\u306f\u3001\u3061\u3087\u3063\u3068\u5fae\u5999\u3067\u3042\u308b\u3002\u3053\u3053\u3089\u3078\u3093\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u306f\u6b27\u7c73\u7cfb\u306e\u8a00\u8a9e\u306b\u7279\u5316\u3057\u305f\u90e8\u5206\u304c\u3042\u308b\u306e\u3067\u3001\u4f7f\u3044\u3065\u3089\u3044\u90e8\u5206\u3082\u3042\u308b\u3002
\n\u305d\u306e\u4ed6\u3001\u30bd\u30fc\u30b9\u306b\u305f\u304f\u3055\u3093\u306e\u4f8b\u304c\u66f8\u3044\u3066\u3042\u308b\u306e\u3067\u3054\u53c2\u7167\u304f\u3060\u3055\u3044\u3002<\/p>\n

rails\/activesupport\/lib\/active_support\/core_ext\/numeric\/time.rb<\/h3>\n

Numeric#second, Numeric#minute, ...<\/h4>\n
2.seconds    # => 2\n2.minutes    # => 120\n2.hours      # => 7200\n1.fortnight  # => 1209600<\/code><\/pre>\n

seconds\u3084minutes\u306a\u3069\u306f\u3001\u5168\u3066alias\u3067\u5358\u6570\u5f62\u3068\u3082\u7d10\u4ed8\u3051\u3089\u308c\u3066\u3044\u308b\u306e\u3067\u30011.second\u3067\u30821.seconds\u3067\u3082\u3069\u3063\u3061\u3067\u3082\u3088\u3044\u3051\u308c\u3069\u3082\u3001\u4e00\u5fdc1.second\u30012.seconds\u3001\u4e00\u822c\u7684\u306b\u306fseconds\u3068\u4f7f\u3046\u306e\u304cRails\u6d41\u3060\u308d\u3046\u304b\u3002<\/p>\n

\u307e\u305f\u3001Numeric#fortnight\u306f2\u9031\u9593\u306e\u79d2\u6570\u3092\u8fd4\u3059\u30022.fortnights\u3060\u3063\u305f\u30894\u9031\u9593\u3002
\n\u3066\u3044\u3046\u304b2\u9031\u9593\u306e\u3053\u3068\u3092\u82f1\u8a9e\u3067fortnight\u3063\u3066\u8a00\u3046\u3053\u3068\u3092\u77e5\u3089\u306a\u304b\u3063\u305f\u3002\u3002\u3002\u65e5\u672c\u3067\u306f\u4e8c\u9031\u9593\u3092\u4e00\u5358\u4f4d\u306b\u3059\u308b\u3068\u3044\u3046\u306e\u306f\u99b4\u67d3\u307f\u304c\u306a\u3044\u3068\u601d\u3046\u306e\u3060\u304c\u3001\u6b27\u7c73\u3060\u3068\u3051\u3063\u3053\u3046\u5f53\u305f\u308a\u524d\u306a\u306e\u304b\u306a\uff1f<\/p>\n

\u3061\u306a\u307f\u306b\u3001Numeric#ago, Numeric#until, Numeric#since, Numeric#from_now\u3068\u3044\u3046\u30e1\u30bd\u30c3\u30c9\u3082\u3042\u308b\u3002<\/p>\n

2.ago # => Sun, 12 Oct 2014 14:29:22 JST +09:00<\/code><\/pre>\n

\u304c\u3001Numeric\u30af\u30e9\u30b9\u306eago\u306a\u3069\u306f\u3001\u79d2\u3060\u3068\u3044\u3046\u3053\u3068\u304c\u5206\u304b\u308a\u306b\u304f\u304f\u8aa4\u4f7f\u7528\u3092\u62db\u304f\u3053\u3068\u304b\u3089\u3001deprecated\u3068\u306a\u3063\u3066\u304a\u308a\u3001Rails 4.2\u3067\u306f\u524a\u9664\u3055\u308c\u308b\u306e\u3067\u30012.ago\u3067\u306f\u306a\u304f2.seconds.ago\u3092\u4f7f\u3046\u3088\u3046\u306b\u3068\u306e\u3053\u3068\u3002<\/p>\n

\u53c2\u8003\uff1a
\nhttps:\/\/github.com\/rails\/rails\/commit\/1f1613604925823be4b15893fbb8f957a38dd0b8<\/a>
https:\/\/github.com\/rails\/rails\/commit\/f1eddea1e3f6faf93581c43651348f48b2b7d8bb<\/a><\/p>\n

Array\u30af\u30e9\u30b9<\/h2>\n

rails\/activesupport\/lib\/active_support\/core_ext\/array\/prepend_and_append.rb<\/h3>\n

Array#append, Array#prepend<\/h4>\n
array << '1'\narray.append('1')<\/code><\/pre>\n

\u914d\u5217\u306b\u8981\u7d20\u3092\u8ffd\u52a0\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u3002
\n\u500b\u4eba\u7684\u306b\u306f\u300c<<\u300d\u306f\u5206\u304b\u308a\u306b\u304f\u3044\u306a\u3042\u3068\u3044\u3064\u3082\u611f\u3058\u308b\u306e\u3067\u3001append\u306f\u3080\u3057\u308d\u672c\u4f53\u306b\u5165\u3063\u3066\u6b32\u3057\u3044\u3050\u3089\u3044\u306e\u611f\u3058\u3067\u3042\u308b\u3002<\/p>\n

\u307e\u3068\u3081<\/h2>\n

\u307e\u3060\u307e\u3060\u8aad\u307f\u59cb\u3081\u305f\u3070\u304b\u308a\u3067\u3059\u304c\u3001Issue\u3084Pull Request\u3092\u8aad\u3093\u3067\u3044\u304f\u306e\u3082\u304a\u3082\u3057\u308d\u3044\u306e\u3067\u3001Active Support\u306b\u9650\u3089\u305a\u5f15\u304d\u7d9a\u304d\u591c\u306a\u591c\u306a\u8aad\u3093\u3067\u3044\u3053\u3046\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n

Ruby on Rails\u3092\u6d3b\u7528\u3057\u305fWeb\u30b5\u30fc\u30d3\u30b9\u3084\u696d\u52d9\u30b7\u30b9\u30c6\u30e0\u958b\u767a<\/a>\u3092\u3054\u691c\u8a0e\u306e\u4f01\u696d\u69d8\u306f\u3001\u662f\u975eMMM\u306b\u3054\u76f8\u8ac7\u4e0b\u3055\u3044\u307e\u305b\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"

Rails\u306eActive Support\u306e\u30bd\u30fc\u30b9\u306f\u6bd4\u8f03\u7684\u8aad\u307f\u3084\u3059\u3044\u3082\u306e\u304c\u591a\u304f\u3001\u304a\u5f79\u7acb\u3061\u30e1\u30bd\u30c3\u30c9\u3082\u3044\u308d\u3044\u308d\u3068\u3042\u308b\u306e\u3067\u3001\u6700\u8fd1\u9152\u306e\u3064\u307e\u307f\u4ee3\u308f\u308a\u306b\u591c\u306a\u591c\u306a\u8aad\u307f\u59cb\u3081\u305f\u4e0b\u689d\u3067\u3059\u3002 \u7279\u306b\u3001Ruby\u306e\u7d44\u307f\u8fbc\u307f\u30af\u30e9\u30b9\u3092\u62e1\u5f35\u3059\u308bCore Extensions\u306e\u30bd\u30fc\u30b9\u3092\u8aad\u3093\u3067\u3044\u308b\u3068\u3001\u77e5\u3089\u306a\u304b\u3063\u305f\u304a\u5f79\u7acb\u3061\u30e1\u30bd\u30c3\u30c9\u304c\u3042\u3063\u305f\u308a\u3001\u3053\u3093\u306a\u3082\u306e\u4f7f\u3046\u3093\u304b\u3044\u306a\u3063\u3066\u30e1\u30bd\u30c3\u30c9\u3082\u3051\u3063\u3053\u3046\u3042\u3063\u305f\u308a\u3067\u304a\u3082\u3057\u308d\u3044\u3002\u5b9f\u969b\u3001\u975e\u5e38\u306b\u5f79\u306b\u7acb\u3064\u30e1\u30bd\u30c3\u30c9\u3082\u3042 […]<\/p>\n","protected":false},"author":4,"featured_media":826,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[9],"tags":[42],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/posts\/133"}],"collection":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/comments?post=133"}],"version-history":[{"count":0,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/posts\/133\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/media\/826"}],"wp:attachment":[{"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/media?parent=133"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/categories?post=133"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/wp-json\/wp\/v2\/tags?post=133"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}