[#37050] [Feature #735] Date#inspect — "rubikitch ." <redmine@...>

Feature #735: Date#inspect

14 messages 2008/11/09

[#37075] [Feature #747] /\A/u ignores BOM — Shyouhei Urabe <redmine@...>

Feature #747: /\A/u ignores BOM

14 messages 2008/11/12

[#37161] m17n of irb — "Yugui (Yuki Sonoda)" <yugui@...>

Yuguiです。

35 messages 2008/11/24
[#37183] Re: m17n of irb — keiju@... (keiju ISHITSUKA) 2008/11/25

けいじゅ@いしつかです.

[#37203] Re: m17n of irb — "Yugui (Yuki Sonoda)" <yugui@...> 2008/11/26

keiju ISHITSUKA さんは書きました:

[#37292] Re: m17n of irb — Yukihiro Matsumoto <matz@...> 2008/12/06

まつもと ゆきひろです

[#37293] Re: m17n of irb — "Yugui (Yuki Sonoda)" <yugui@...> 2008/12/07

Yuguiです。

[#37298] Re: m17n of irb — Yukihiro Matsumoto <matz@...> 2008/12/07

まつもと ゆきひろです

[#37210] RSS::Maker.create(version) — "Akinori MUSHA" <knu@...>

 RSS::Maker で、 "2.0" 等の文字列でフィードのフォーマットを渡す

15 messages 2008/11/27

[#37213] Re: [ruby-cvs:27586] Ruby:r20368 (trunk): * ext/bigdecimal/bigdecimal.c (BigDecimal_div2): should return — Tadayoshi Funaba <tadf@...>

> * ext/bigdecimal/bigdecimal.c (BigDecimal_div2): should return

8 messages 2008/11/27

[ruby-dev:37058] Re: [Feature #735] Date#inspect

From: Hiroshi Moriyama <hiroshi@...>
Date: 2008-11-10 21:56:20 UTC
List: ruby-dev #37058
Yukihiro Matsumoto wrote:
> どこかに妥協点があるとよいのですが。ただ、私はinspectがto_s
> と同様の「人間にわかりやすい日付(DateTimeの場合は時間も)」の
> 表現 も 含むことを期待します。

デバッグモードのときだけ詳細な情報を返すというのはどうでしょうか。

例:

% ruby1.9 -rdate -e 'p Date.today' 
2008-11-11 

% ruby1.9 -rdate -e 'p Date.today' -d 
#<Date: "2008-11-11", @ajd=4909563/2, @of=0, @sg=2299161> 

% ruby1.9 -rdate -e 'p DateTime.now' 
2008-11-11T06:24:32+09:00 

% ruby1.9 -rdate -e 'p DateTime.now' -d 
#<DateTime: "2008-11-11T06:24:32+09:00", @ajd=21209311227209169197/8640000000000, @of=3/8, @sg=2299161> 

パッチ:

Index: lib/date.rb
===================================================================
--- lib/date.rb	(revision 20171)
+++ lib/date.rb	(working copy)
@@ -1469,8 +1469,15 @@
   # Calculate a hash value for this date.
   def hash() @ajd.hash end
 
-  # Return internal object state as a programmer-readable string.
-  def inspect() format('#<%s: %s,%s,%s>', self.class, @ajd, @of, @sg) end
+  # If +$DEBUG+ is true, returns internal object state as a programmer-readable
+  # string. Otherwise the same as +to_s+.
+  def inspect
+    if $DEBUG
+      format('#<%s: %s @ajd=%s, @of=%s, @sg=%s, "%s">', to_s, self.class, @ajd, @of, @sg)
+    else
+      to_s
+    end
+  end
 
   # Return the date as a human-readable string.
   #



In This Thread