Time.now + str $B$H(B #to_r

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

[ruby-core:23729]e$B$G;XE&$5$l$?e(BTimee$B$He(Bstringe$B$N2C;;$,%(%i!<$K$Je(B
e$B$i$J$$M}M3$O!"e(B1.9e$B$Ge(BRationale$B$,AH$_9~$^$l$?$3$H$G!"e(B

  • String#to_re$B$,Ds6!$5$l$?e(B

String#to_re$B$Oe(BRationale$B$H$7$F2r<a$G$-$J$$J8;zNs$Ke(B0e$B$rJV$9e(B

  • timee$B$,FbIt7W;;$Ke(BRationale$B$r;H$&$h$&$K$J$C$?e(B
  • timee$B$,%*%Z%i%s%I$NJQ49$Ke(Bto_re$B$r;H$&$h$&$K$J$C$?e(B

e$B$H$$$&%3%s%$K$h$C$FH/@8$7$^$7$?!#$$$A$$&!"e(BTime#+e$B$N@5Ev$J0ze(B
e$B?t$H$7$FJ8;zNse(B(T_STRINGe$B$
$h$Se(Bto_stre$B$r;}$D%*%V%8%’%/%He(B)e$B$r30$9e(B
e$B$H$$$&BP1~$r9T$$$^$7$?$,!"@8<Q$(46$,$L$0$($^$;$s!#e(B

e$B5$$KF~$i$J$$860x$r2~$a$F9M$($F$_$^$7$?$,!"$I$&$d$i0J2<$NJ#9ge(B
e$B$N$h$&$G$9!#e(B

to_re$B$H$$$&L>A0$O$h$/$J$$!#e(Bre$B$,e(Brationale$B$@$+e(Bregexpe$B$@$+e(Brange
e$B$@$+$o$+$i$J$$!#D9G/$NMxMQ$G$b$&DjCe$7$F$7$^$C$?e(B
s(string), i(integer), a(array)e$B$O;EJ}$,$J$$$H$7$F$b!"$3$le(B
e$B0J>ee(B1e$BJ8;ze(Bto_?e$B%a%=%C%I$rA}$d$9$Y$-$G$O$J$$!#$3$NE@$G$Oe(B
BigDecimal#to_de$B$bF1:ae(B

Timee$B$,e(Bto_re$B$r;H$C$F$$$k$N$b$h$/$J$$!#L>A0$,NI$/$J$$$3$H$K2Ce(B
e$B$($F!"%%Z%i%s%I$N0EL[$N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$K$7$?J}$,$h$$$h$&$K;W$&$H$3$m!“e(B
as_xxx e$B$H$$$&$N$O$A$g$C$H<e$$$s$8$c$J$$$G$7$g$&$+!#e(B
convert_xxx e$B$H$+e(B cast_xxx
e$B$H$+!”$b$C$H$$$+$K$b$J%a%=%C%IL>$N$[$&$,e(B
e$B$$$$$h$&$K46$8$^$9!#e(B

e$B$"$H!"8=>u$G$OL@<(E*$JJQ49$NJ}$Oe(B

“foo”.to_i # => 0

e$B$N$h$&$J!“$o$j$H%+%8%e%”%k$JJQ49$r$7$F$$$^$9$,!“$3$l$O$&$l$7e(B
e$B$$$3$H$,>/$J$$$N$G!”:#8e?7$?$KDI2C$9$k>l9g$Oe(B(Raional e$B$b4^$ae(B
e$B$Fe(B)e$B!“%(%i!<$r$”$2$k$Y$-$G$O$J$$$+$H;W$&$h$&$K$J$j$^$7$?$,!"$3e(B
e$B$l$O$^$?JL$NOC$H$7$F5DO@$9$Y$-$G$7$g$&!#e(B

String#to_i / NilClass#to_i e$B$K4X$7$F$O$?$^$K;H$$$^$9!#e(B
Xi Bot for nadoka · GitHub e$BNc$($P$3$le(B
e$B30$+$iMh$?F~NO$r?tCM$KJQ49$7$?>e$GCM0h$r8+$?$$>l9g$K;H$C$F$$$^$9!#e(B
e$B$b$C$H$b!“$3$l$Oe(B NilClass#to_i
e$B$,$”$k$H$$$&FC<l@-$+$iMh$F$$$k$N$G!“e(B
e$B$3$l$+$i30$l$k$b$N$K$O$”$?$i$J$$$+$b$7$l$^$;$s$,!#e(B

NilClass#to_r e$B$O8=:B8:$9$ke(B

e$B$`$i$?$G$9!#e(B

On 2009/12/07, at 14:36, NARUSE, Yui wrote:

e$B$G!“L@<(E*$JJQ49$H0EL[E*$JJQ49$N$?$a$NL?L>86B’$O$I$N$h$&$J$be(B
e$B$N$,$h$$$N$+!”$H$$$&E@$K$D$$$F!"$$$m$$$m$H$40U8+$rJ9$+$;$F$/e(B
e$B$@$5$$$^$;!#e(B

e$B0EL[EJQ49$,e(B to_xxx e$B$G$“$k!”$H$$$&$3$H$,!"8_49@-E$KF0$+$;$J$$0J>e!"e(B
e$BL@<(EJQ49$r$$$+$K$b!VL@<(E!W$J%a%=%C%I$K$7$?J}$,$h$$$h$&$K;W$&$H$3$m!“e(B
as_xxx e$B$H$$$&$N$O$A$g$C$H<e$$$s$8$c$J$$$G$7$g$&$+!#e(B
convert_xxx e$B$H$+e(B cast_xxx e$B$H$+!”$b$C$H$$$+$K$b$J%a%=%C%IL>$N$[$&$,e(B
e$B$$$$$h$&$K46$8$^$9!#e(B

convert_to(Rational) e$B$H$+e(B cast_to(Rational) e$B$N$h$&$K!"e(B
e$BJQ49@h$N%/%i%9$r0z?t$H$7$FM?$($kJ}K!$OG!2?$G$7$g$&!)e(B


Kenta M.
OpenPGP FP = FA26 35D7 4F98 3498 0810 E0D5 F213 966F E9EB 0BCC

e$BK$r=q$-$^$7$?e(B!!
e$B!Xe(BRuby e$B5U0z$-%l%7%T!Ye(B

E-mail: [email protected]
twitter: http://twitter.com/mrkn/
blog: ドレッシングのような

2009e$BG/e(B12e$B7ne(B7e$BF|e(B12:42 Yukihiro M.
[email protected]:

e$B$3$N%Q%C%A$N:GBg$N<eE@$O:n$C$?K?M$be(Btoe$B$He(Base$B$,$I$C$A$,$I$C$A$@e(B
e$B$+K:$l$F$7$^$&$H$$$&$H$3$m$G$7$g$&!#$^$?!“JQ99$N5,LO$,Bg$-$$e(B
e$B$N$Ge(B1.9.2e$B$K$O<jCY$l$H$$$&46$b$”$j$^$9!#;d$H$7$F$Oe(Bto_re$B$de(Bto_de$B$,e(B
e$B$3$l0J>e9-$^$i$J$$$&$A$K<j$rBG$A$?$$$N$G$9$,!"$=$N$X$s$Oe(B
Yuguie$B$5$s$NH=CG$KG$$;$k$H$7$F!#e(B

to e$B$He(B as e$B$,F1$8D9$5$J$N$,$h$m$7$/$J$$$N$G$O$J$$$G$9$+$M$'!#e(B

intern_to_rational e$B$H$+!#e(B

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:39877] Re: Time.now + str e$B$He(B #to_r
on Mon, 14 Dec 2009 09:02:24 +0900, Kenta M. [email protected]
writes:

|convert_to(Rational) e$B$H$+e(B cast_to(Rational) e$B$N$h$&$K!"e(B
|e$BJQ49@h$N%/%i%9$r0z?t$H$7$FM?$($kJ}K!$OG!2?$G$7$g$&!)e(B

e$B$=$N>l9g!“e(Bconvert_toe$B$H$+e(Bcast_toe$B$H$+$N%a%=%C%I$N<BAu$NCf$G!”%/e(B
e$B%i%9$4$H$K>r7oJ,4t$9$k$N$G$“$l$P!”?7$?$K?t%/%i%9$,A}$($?>l9ge(B
e$B$KBP1~$9$k$N$,Fq$7$/$J$k$N$G$O$J$$$G$7$g$&$+!#<BAu$H$7$F%@%Ve(B
e$B%k%G%#%9%Q%C%A$r;H$($P!“7k6I$O$J$s$i$+$N%a%=%C%IL>$r9M$($kI,e(B
e$BMW$,$”$k$N$G$O$J$$$+$H!#e(B

e$B$`$i$?$G$9!#e(B

On 2009/12/17, at 1:41, Yukihiro M. wrote:

e$B$KBP1~$9$k$N$,Fq$7$/$J$k$N$G$O$J$$$G$7$g$&$+!#<BAu$H$7$F%@%Ve(B
e$B%k%G%#%9%Q%C%A$r;H$($P!“7k6I$O$J$s$i$+$N%a%=%C%IL>$r9M$($kI,e(B
e$BMW$,$”$k$N$G$O$J$$$+$H!#e(B

e$B<+J,$,CN$i$J$$%/%i%9$X$NJQ49;~$K%@%V%k%G%#%9%Q%C%A$G8F$S=P$9%/%i%9%a%=%C%I$re(B
convert_from
e$B$H$$$&L>A0$K7h$a$l$P!"$3$N>l9g$K$D$$$F$OBP>NE*$K$J$C$FH~$7$$$H;W$$$^$9!#e(B


Kenta M.
OpenPGP FP = FA26 35D7 4F98 3498 0810 E0D5 F213 966F E9EB 0BCC

e$BK$r=q$-$^$7$?e(B!!
e$B!Xe(BRuby e$B5U0z$-%l%7%T!Ye(B

E-mail: [email protected]
twitter: http://twitter.com/mrkn/
blog: ドレッシングのような

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:39915] Re: Time.now + str e$B$He(B #to_r
on Thu, 24 Dec 2009 09:06:06 +0900, Kenta M. [email protected]
writes:

|> e$B$=$N>l9g!“e(Bconvert_toe$B$H$+e(Bcast_toe$B$H$+$N%a%=%C%I$N<BAu$NCf$G!”%/e(B
|> e$B%i%9$4$H$K>r7oJ,4t$9$k$N$G$“$l$P!”?7$?$K?t%/%i%9$,A}$($?>l9ge(B
|> e$B$KBP1~$9$k$N$,Fq$7$/$J$k$N$G$O$J$$$G$7$g$&$+!#<BAu$H$7$F%@%Ve(B
|> e$B%k%G%#%9%Q%C%A$r;H$($P!“7k6I$O$J$s$i$+$N%a%=%C%IL>$r9M$($kI,e(B
|> e$BMW$,$”$k$N$G$O$J$$$+$H!#e(B
|
|e$B<+J,$,CN$i$J$$%/%i%9$X$NJQ49;~$K%@%V%k%G%#%9%Q%C%A$G8F$S=P$9%/%i%9%a%=%C%I$re(B
|convert_from e$B$H$$$&L>A0$K7h$a$l$P!"$3$N>l9g$K$D$$$F$OBP>NE*$K$J$C$FH~$7$$$H;W$$$^$9!#e(B

e$B$J$s$H$J$/M}2r$G$-$?5$$,$7$J$$$N$G!"$b$&$A$g$C$H@bL@$7$F$b$ie(B
e$B$($^$;$s$+!#e(B

e$B2>$Ke(BRationale$B$H$$$&AH$9~$$G$J$$%/%i%9$,$"$C$?$H$7$F!"e(B

r = 2.convert_to(Rational)

e$B$O6qBNE*$K$O$I$s$J=hM}$r$9$k$N$G$7$g$&!)e(B
e$B$?$@$7!"e(BRationale$B$OAHe(B
e$B$9~$$G$O$J$$$N$G!"e(B2e$B$Oe(BRationale$B$H$$$&%/%i%9$K$D$$$FCN$i$J$$$3e(B
e$B$H$H$7$^$9!#e(B

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:39925] Re: Time.now + str e$B$He(B #to_r
on Thu, 24 Dec 2009 20:26:49 +0900, Kenta M. [email protected]
writes:

|def convert_to(target_klass)
| case target_klass
| when e$BCN$C$F$k%/%i%9e(B1
| e$BJQ49=hM}e(B1
| when e$BCN$C$F$k%/%i%9e(B2
| e$BJQ49=hM}e(B2
| when …
| …
| else
| target_klass.convert_from(self)
| end
|end
|
|e$B$3$s$J%a%=%C%I$rA[Dj$7$F$$$^$7$?!#e(B

e$B$3$N$d$jJ}$@$HMF0W$KL58B%k!<%W$KMn$A$^$;$s!)e(B

e$B$`$i$?$G$9!#e(B

On 2009/12/24, at 9:28, Yukihiro M. wrote:

|convert_from e$B$H$$$&L>A0$K7h$a$l$P!"$3$N>l9g$K$D$$$F$OBP>NE*$K$J$C$FH~$7$$$H;W$$$^$9!#e(B
e$B$H$H$7$^$9!#e(B

def convert_to(target_klass)
case target_klass
when e$BCN$C$F$k%/%i%9e(B1
e$BJQ49=hM}e(B1
when e$BCN$C$F$k%/%i%9e(B2
e$BJQ49=hM}e(B2
when …

else
target_klass.convert_from(self)
end
end

e$B$3$s$J%a%=%C%I$rA[Dj$7$F$$$^$7$?!#e(B


Kenta M.
OpenPGP FP = FA26 35D7 4F98 3498 0810 E0D5 F213 966F E9EB 0BCC

e$BK$r=q$-$^$7$?e(B!!
e$B!Xe(BRuby e$B5U0z$-%l%7%T!Ye(B

E-mail: [email protected]
twitter: http://twitter.com/mrkn/
blog: ドレッシングのような