ruby-oci8 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +13 -0
- data/ChangeLog +104 -0
- data/NEWS +337 -235
- data/README.md +38 -0
- data/VERSION +1 -1
- data/dist-files +7 -6
- data/docs/install-binary-package.md +40 -0
- data/docs/install-full-client.md +116 -0
- data/docs/install-instant-client.md +167 -0
- data/docs/platform-specific-issues.md +209 -0
- data/docs/report-installation-issue.md +50 -0
- data/ext/oci8/apiwrap.yml +37 -14
- data/ext/oci8/error.c +26 -11
- data/ext/oci8/extconf.rb +19 -3
- data/ext/oci8/lob.c +287 -0
- data/ext/oci8/oci8.c +15 -9
- data/ext/oci8/oci8.h +8 -0
- data/ext/oci8/oci8lib.c +7 -2
- data/ext/oci8/ocihandle.c +209 -99
- data/ext/oci8/ocinumber.c +430 -147
- data/ext/oci8/oradate.c +92 -75
- data/ext/oci8/stmt.c +30 -12
- data/ext/oci8/win32.c +22 -0
- data/lib/oci8/bindtype.rb +1 -0
- data/lib/oci8/connection_pool.rb +1 -0
- data/lib/oci8/encoding-init.rb +1 -0
- data/lib/oci8/object.rb +29 -4
- data/lib/oci8/oci8.rb +75 -17
- data/lib/oci8/ocihandle.rb +192 -12
- data/lib/oci8/oracle_version.rb +47 -41
- data/lib/oci8/properties.rb +19 -0
- data/pre-distclean.rb +2 -2
- data/ruby-oci8.gemspec +7 -3
- data/test/config.rb +1 -6
- data/test/test_datetime.rb +70 -32
- data/test/test_oci8.rb +8 -2
- metadata +35 -53
- data/README +0 -5
- data/doc/api.en.html +0 -527
- data/doc/api.en.rd +0 -554
- data/doc/api.ja.html +0 -525
- data/doc/api.ja.rd +0 -557
- data/doc/manual.css +0 -35
data/ext/oci8/ocinumber.c
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
/*
|
3
3
|
* ocinumber.c
|
4
4
|
*
|
5
|
-
* Copyright (C) 2005-
|
5
|
+
* Copyright (C) 2005-2012 KUBO Takehiro <kubo@jiubao.org>
|
6
6
|
*
|
7
7
|
*/
|
8
8
|
#include "oci8.h"
|
@@ -112,7 +112,9 @@ static VALUE onum_s_alloc(VALUE klass)
|
|
112
112
|
return obj;
|
113
113
|
}
|
114
114
|
|
115
|
-
/*
|
115
|
+
/*
|
116
|
+
* OCINumber (C datatype) -> OraNumber (ruby object)
|
117
|
+
*/
|
116
118
|
VALUE oci8_make_ocinumber(OCINumber *s, OCIError *errhp)
|
117
119
|
{
|
118
120
|
VALUE obj;
|
@@ -123,6 +125,9 @@ VALUE oci8_make_ocinumber(OCINumber *s, OCIError *errhp)
|
|
123
125
|
return obj;
|
124
126
|
}
|
125
127
|
|
128
|
+
/*
|
129
|
+
* OCINumber (C datatype) -> Integer (ruby object)
|
130
|
+
*/
|
126
131
|
VALUE oci8_make_integer(OCINumber *s, OCIError *errhp)
|
127
132
|
{
|
128
133
|
signed long sl;
|
@@ -141,12 +146,17 @@ VALUE oci8_make_integer(OCINumber *s, OCIError *errhp)
|
|
141
146
|
rb_raise(eOCIException, "Invalid internal number format: %s", buf);
|
142
147
|
}
|
143
148
|
|
149
|
+
/*
|
150
|
+
* OCINumber (C datatype) -> Float (ruby object)
|
151
|
+
*/
|
144
152
|
VALUE oci8_make_float(OCINumber *s, OCIError *errhp)
|
145
153
|
{
|
146
154
|
return rb_float_new(oci8_onum_to_dbl(s, errhp));
|
147
155
|
}
|
148
156
|
|
149
|
-
/*
|
157
|
+
/*
|
158
|
+
* String (ruby object) -> OCINumber (C datatype)
|
159
|
+
*/
|
150
160
|
static void set_oci_number_from_str(OCINumber *result, VALUE str, VALUE fmt, VALUE nls_params, OCIError *errhp)
|
151
161
|
{
|
152
162
|
oratext *fmt_ptr;
|
@@ -190,8 +200,11 @@ static void set_oci_number_from_str(OCINumber *result, VALUE str, VALUE fmt, VAL
|
|
190
200
|
result));
|
191
201
|
}
|
192
202
|
|
193
|
-
/*
|
194
|
-
|
203
|
+
/*
|
204
|
+
* Numeric (ruby object) -> OCINumber (C datatype)
|
205
|
+
*
|
206
|
+
* @return 1 on success. Otherwise, 0.
|
207
|
+
*/
|
195
208
|
static int set_oci_number_from_num(OCINumber *result, VALUE num, int force, OCIError *errhp)
|
196
209
|
{
|
197
210
|
signed long sl;
|
@@ -287,6 +300,9 @@ is_not_big_decimal:
|
|
287
300
|
return 0;
|
288
301
|
}
|
289
302
|
|
303
|
+
/*
|
304
|
+
* Numeric (ruby object) -> OCINumber (C datatype)
|
305
|
+
*/
|
290
306
|
OCINumber *oci8_set_ocinumber(OCINumber *result, VALUE self, OCIError *errhp)
|
291
307
|
{
|
292
308
|
set_oci_number_from_num(result, self, 1, errhp);
|
@@ -294,6 +310,9 @@ OCINumber *oci8_set_ocinumber(OCINumber *result, VALUE self, OCIError *errhp)
|
|
294
310
|
}
|
295
311
|
#define TO_OCINUM oci8_set_ocinumber
|
296
312
|
|
313
|
+
/*
|
314
|
+
* Numeric (ruby object) -> OCINumber (C datatype) as an integer
|
315
|
+
*/
|
297
316
|
OCINumber *oci8_set_integer(OCINumber *result, VALUE self, OCIError *errhp)
|
298
317
|
{
|
299
318
|
OCINumber work;
|
@@ -303,6 +322,9 @@ OCINumber *oci8_set_integer(OCINumber *result, VALUE self, OCIError *errhp)
|
|
303
322
|
return result;
|
304
323
|
}
|
305
324
|
|
325
|
+
/*
|
326
|
+
* OCINumber (C datatype) -> double (C datatype)
|
327
|
+
*/
|
306
328
|
double oci8_onum_to_dbl(OCINumber *s, OCIError *errhp)
|
307
329
|
{
|
308
330
|
if (oci8_float_conversion_type_is_ruby) {
|
@@ -330,14 +352,15 @@ double oci8_onum_to_dbl(OCINumber *s, OCIError *errhp)
|
|
330
352
|
}
|
331
353
|
}
|
332
354
|
|
355
|
+
/*
|
356
|
+
* double (C datatype) -> OCINumber (C datatype)
|
357
|
+
*/
|
333
358
|
OCINumber *oci8_dbl_to_onum(OCINumber *result, double dbl, OCIError *errhp)
|
334
359
|
{
|
335
|
-
|
336
|
-
case FP_NAN:
|
360
|
+
if (isnan(dbl)) {
|
337
361
|
rb_raise(rb_eFloatDomainError, "NaN");
|
338
362
|
/* never reach here */
|
339
|
-
|
340
|
-
case FP_INFINITE:
|
363
|
+
} else if (isinf(dbl)) {
|
341
364
|
if (dbl > 0.0) {
|
342
365
|
oranumber_from_str(result, "~", 1);
|
343
366
|
} else {
|
@@ -361,12 +384,25 @@ OCINumber *oci8_dbl_to_onum(OCINumber *result, double dbl, OCIError *errhp)
|
|
361
384
|
return result;
|
362
385
|
}
|
363
386
|
|
387
|
+
/*
|
388
|
+
* Document-module: OCI8::Math
|
389
|
+
*
|
390
|
+
* The <code>OCI8::Math</code> module contains module functions for basic
|
391
|
+
* trigonometric and transcendental functions. Their accuracy is
|
392
|
+
* same with {OraNumber}.
|
393
|
+
*/
|
394
|
+
|
364
395
|
/*
|
365
396
|
* call-seq:
|
366
|
-
*
|
397
|
+
* atan2(y, x)
|
367
398
|
*
|
368
|
-
* Computes the arc tangent
|
369
|
-
*
|
399
|
+
* Computes the principal value of the arc tangent of <i>y/x</i>,
|
400
|
+
* using the signs of both arguments to determine the quadrant of the
|
401
|
+
* return value.
|
402
|
+
*
|
403
|
+
* @param [Numeric] y
|
404
|
+
* @param [Numeric] x
|
405
|
+
* @return [OraNumber] Computed value in the range [-{PI}, {PI}]
|
370
406
|
*/
|
371
407
|
static VALUE omath_atan2(VALUE self, VALUE Ycoordinate, VALUE Xcoordinate)
|
372
408
|
{
|
@@ -399,10 +435,12 @@ static VALUE omath_atan2(VALUE self, VALUE Ycoordinate, VALUE Xcoordinate)
|
|
399
435
|
|
400
436
|
/*
|
401
437
|
* call-seq:
|
402
|
-
*
|
438
|
+
* cos(x)
|
439
|
+
*
|
440
|
+
* Computes the cosine of <i>x</i>, measured in radians.
|
403
441
|
*
|
404
|
-
*
|
405
|
-
* -1
|
442
|
+
* @param [Numeric] x
|
443
|
+
* @return [OraNumber] Computed value in the range [-1, 1]
|
406
444
|
*/
|
407
445
|
static VALUE omath_cos(VALUE obj, VALUE radian)
|
408
446
|
{
|
@@ -416,10 +454,12 @@ static VALUE omath_cos(VALUE obj, VALUE radian)
|
|
416
454
|
|
417
455
|
/*
|
418
456
|
* call-seq:
|
419
|
-
*
|
457
|
+
* sin(x)
|
420
458
|
*
|
421
|
-
* Computes the sine of <i>x</i
|
422
|
-
*
|
459
|
+
* Computes the sine of <i>x</i>, measured in radians.
|
460
|
+
*
|
461
|
+
* @param [Numeric] x
|
462
|
+
* @return [OraNumber] Computed value in the range [-1, 1]
|
423
463
|
*/
|
424
464
|
static VALUE omath_sin(VALUE obj, VALUE radian)
|
425
465
|
{
|
@@ -433,9 +473,12 @@ static VALUE omath_sin(VALUE obj, VALUE radian)
|
|
433
473
|
|
434
474
|
/*
|
435
475
|
* call-seq:
|
436
|
-
*
|
476
|
+
* tan(x)
|
477
|
+
*
|
478
|
+
* Computes the tangent of <i>x</i>, measured in radians.
|
437
479
|
*
|
438
|
-
*
|
480
|
+
* @param [Numeric] x
|
481
|
+
* @return [OraNumber]
|
439
482
|
*/
|
440
483
|
static VALUE omath_tan(VALUE obj, VALUE radian)
|
441
484
|
{
|
@@ -449,9 +492,12 @@ static VALUE omath_tan(VALUE obj, VALUE radian)
|
|
449
492
|
|
450
493
|
/*
|
451
494
|
* call-seq:
|
452
|
-
*
|
495
|
+
* acos(x)
|
453
496
|
*
|
454
|
-
* Computes the arc cosine of <i>x</i>.
|
497
|
+
* Computes the principal value of the arc cosine of <i>x</i>.
|
498
|
+
*
|
499
|
+
* @param [Numeric] x
|
500
|
+
* @return [OraNumber] Computed value in the range [0, {PI}]
|
455
501
|
*/
|
456
502
|
static VALUE omath_acos(VALUE obj, VALUE num)
|
457
503
|
{
|
@@ -476,9 +522,12 @@ static VALUE omath_acos(VALUE obj, VALUE num)
|
|
476
522
|
|
477
523
|
/*
|
478
524
|
* call-seq:
|
479
|
-
*
|
525
|
+
* asin(x)
|
526
|
+
*
|
527
|
+
* Computes the principal value of the arc sine of <i>x</i>.
|
480
528
|
*
|
481
|
-
*
|
529
|
+
* @param [Numeric] x
|
530
|
+
* @return [OraNumber] Computed value in the range [-{PI}/2, {PI}]/2]
|
482
531
|
*/
|
483
532
|
static VALUE omath_asin(VALUE obj, VALUE num)
|
484
533
|
{
|
@@ -503,9 +552,12 @@ static VALUE omath_asin(VALUE obj, VALUE num)
|
|
503
552
|
|
504
553
|
/*
|
505
554
|
* call-seq:
|
506
|
-
*
|
555
|
+
* atan(x)
|
507
556
|
*
|
508
|
-
* Computes the arc tangent of <i>x</i>.
|
557
|
+
* Computes the principal value of the arc tangent of their argument <i>x</i>.
|
558
|
+
*
|
559
|
+
* @param [Numeric] x
|
560
|
+
* @return [OraNumber] Computed value in the range [-{PI}/2, {PI}/2]
|
509
561
|
*/
|
510
562
|
static VALUE omath_atan(VALUE obj, VALUE num)
|
511
563
|
{
|
@@ -519,9 +571,12 @@ static VALUE omath_atan(VALUE obj, VALUE num)
|
|
519
571
|
|
520
572
|
/*
|
521
573
|
* call-seq:
|
522
|
-
*
|
574
|
+
* cosh(x)
|
575
|
+
*
|
576
|
+
* Computes the hyperbolic cosine of <i>x</i>.
|
523
577
|
*
|
524
|
-
*
|
578
|
+
* @param [Numeric] x
|
579
|
+
* @return [OraNumber]
|
525
580
|
*/
|
526
581
|
static VALUE omath_cosh(VALUE obj, VALUE num)
|
527
582
|
{
|
@@ -535,10 +590,12 @@ static VALUE omath_cosh(VALUE obj, VALUE num)
|
|
535
590
|
|
536
591
|
/*
|
537
592
|
* call-seq:
|
538
|
-
*
|
593
|
+
* sinh(x)
|
539
594
|
*
|
540
|
-
* Computes the hyperbolic sine of <i>x</i
|
541
|
-
*
|
595
|
+
* Computes the hyperbolic sine of <i>x</i>.
|
596
|
+
*
|
597
|
+
* @param [Numeric] x
|
598
|
+
* @return [OraNumber]
|
542
599
|
*/
|
543
600
|
static VALUE omath_sinh(VALUE obj, VALUE num)
|
544
601
|
{
|
@@ -552,10 +609,12 @@ static VALUE omath_sinh(VALUE obj, VALUE num)
|
|
552
609
|
|
553
610
|
/*
|
554
611
|
* call-seq:
|
555
|
-
*
|
612
|
+
* tanh(x)
|
613
|
+
*
|
614
|
+
* Computes the hyperbolic tangent of <i>x</i>.
|
556
615
|
*
|
557
|
-
*
|
558
|
-
*
|
616
|
+
* @param [Numeric] x
|
617
|
+
* @return [OraNumber]
|
559
618
|
*/
|
560
619
|
static VALUE omath_tanh(VALUE obj, VALUE num)
|
561
620
|
{
|
@@ -569,9 +628,12 @@ static VALUE omath_tanh(VALUE obj, VALUE num)
|
|
569
628
|
|
570
629
|
/*
|
571
630
|
* call-seq:
|
572
|
-
*
|
631
|
+
* exp(x)
|
573
632
|
*
|
574
|
-
*
|
633
|
+
* Computes the base- <i>e</i> exponential of <i>x</i>.
|
634
|
+
*
|
635
|
+
* @param [Numeric] x
|
636
|
+
* @return [OraNumber]
|
575
637
|
*/
|
576
638
|
static VALUE omath_exp(VALUE obj, VALUE num)
|
577
639
|
{
|
@@ -584,12 +646,20 @@ static VALUE omath_exp(VALUE obj, VALUE num)
|
|
584
646
|
}
|
585
647
|
|
586
648
|
/*
|
587
|
-
*
|
588
|
-
*
|
589
|
-
*
|
649
|
+
* @overload log(x)
|
650
|
+
*
|
651
|
+
* Computes the natural logarithm of <i>x</i>.
|
652
|
+
*
|
653
|
+
* @param [Numeric] x
|
654
|
+
* @return [OraNumber]
|
655
|
+
*
|
656
|
+
* @overload log(x, y)
|
590
657
|
*
|
591
|
-
*
|
592
|
-
*
|
658
|
+
* Computes the base <i>y</I> logarithm of <i>x</i>.
|
659
|
+
*
|
660
|
+
* @param [Numeric] x
|
661
|
+
* @param [Numeric] y
|
662
|
+
* @return [OraNumber]
|
593
663
|
*/
|
594
664
|
static VALUE omath_log(int argc, VALUE *argv, VALUE obj)
|
595
665
|
{
|
@@ -622,9 +692,12 @@ static VALUE omath_log(int argc, VALUE *argv, VALUE obj)
|
|
622
692
|
|
623
693
|
/*
|
624
694
|
* call-seq:
|
625
|
-
*
|
695
|
+
* log10(x)
|
696
|
+
*
|
697
|
+
* Computes the base 10 logarithm of <i>x</i>.
|
626
698
|
*
|
627
|
-
*
|
699
|
+
* @param [Numeric] x
|
700
|
+
* @return [OraNumber]
|
628
701
|
*/
|
629
702
|
static VALUE omath_log10(VALUE obj, VALUE num)
|
630
703
|
{
|
@@ -643,9 +716,12 @@ static VALUE omath_log10(VALUE obj, VALUE num)
|
|
643
716
|
|
644
717
|
/*
|
645
718
|
* call-seq:
|
646
|
-
*
|
719
|
+
* sqrt(x)
|
647
720
|
*
|
648
|
-
*
|
721
|
+
* Computes the square root of <i>x</i>.
|
722
|
+
*
|
723
|
+
* @param [Numeric] x
|
724
|
+
* @return [OraNumber]
|
649
725
|
*/
|
650
726
|
static VALUE omath_sqrt(VALUE obj, VALUE num)
|
651
727
|
{
|
@@ -665,12 +741,39 @@ static VALUE omath_sqrt(VALUE obj, VALUE num)
|
|
665
741
|
return oci8_make_ocinumber(&r, errhp);
|
666
742
|
}
|
667
743
|
|
744
|
+
/*
|
745
|
+
* Document-class: OraNumber
|
746
|
+
*
|
747
|
+
* OraNumber is a ruby representation of
|
748
|
+
* {http://docs.oracle.com/cd/E11882_01/server.112/e17118/sql_elements001.htm#sthref118 Oracle NUMBER data type}.
|
749
|
+
* without precision and scale designators.
|
750
|
+
*/
|
668
751
|
|
669
752
|
/*
|
670
753
|
* call-seq:
|
671
|
-
*
|
754
|
+
* OraNumber(expr = nil, fmt = nil, nlsparam = nil)
|
755
|
+
*
|
756
|
+
* Converts <i>expr</i> to a value of OraNumber. The <i>expr</i> can be a Numeric value
|
757
|
+
* or a String value. If it is a String value, optional <i>fmt</i> and <i>nlsparam</i>.
|
758
|
+
* is used as {http://docs.oracle.com/cd/E11882_01/server.112/e17118/functions211.htm Oracle SQL function TO_NUMBER}
|
759
|
+
* does.
|
760
|
+
*
|
761
|
+
* @example
|
762
|
+
* # Numeric expr
|
763
|
+
* OraNumber(123456.789) # -> 123456.789
|
764
|
+
* # String expr
|
765
|
+
* OraNumber('123456.789') # -> 123456.789
|
766
|
+
* # String expr with fmt
|
767
|
+
* OraNumber('123,456.789', '999,999,999.999') # -> 123456.789
|
768
|
+
* # String expr with fmt and nlsparam
|
769
|
+
* OraNumber('123.456,789', '999G999G999D999', "NLS_NUMERIC_CHARACTERS = ',.'") # -> 123456.789
|
672
770
|
*
|
673
|
-
*
|
771
|
+
* @param [String, Numeric] expr
|
772
|
+
* @param [String] fmt
|
773
|
+
* @param [String] nlsparam
|
774
|
+
* @return [OraNumber]
|
775
|
+
*
|
776
|
+
* @since 2.0.3
|
674
777
|
*/
|
675
778
|
static VALUE onum_f_new(int argc, VALUE *argv, VALUE self)
|
676
779
|
{
|
@@ -679,6 +782,29 @@ static VALUE onum_f_new(int argc, VALUE *argv, VALUE self)
|
|
679
782
|
return obj;
|
680
783
|
}
|
681
784
|
|
785
|
+
/*
|
786
|
+
* call-seq:
|
787
|
+
* initialize(expr = nil, fmt = nil, nlsparam = nil)
|
788
|
+
*
|
789
|
+
* Creates a value of OraNumber from <i>expr</i>. The <i>expr</i> can be a Numeric value
|
790
|
+
* or a String value. If it is a String value, optional <i>fmt</i> and <i>nlsparam</i>
|
791
|
+
* is used as {http://docs.oracle.com/cd/E11882_01/server.112/e17118/functions211.htm Oracle SQL function TO_NUMBER}
|
792
|
+
* does.
|
793
|
+
*
|
794
|
+
* @example
|
795
|
+
* # Numeric expr
|
796
|
+
* OraNumber.new(123456.789) # -> 123456.789
|
797
|
+
* # String expr
|
798
|
+
* OraNumber.new('123456.789') # => #<OraNumber:123456.789>
|
799
|
+
* # String expr with fmt
|
800
|
+
* OraNumber.new('123,456.789', '999,999,999.999') # => #<OraNumber:123456.789>
|
801
|
+
* # String expr with fmt and nlsparam
|
802
|
+
* OraNumber.new('123.456,789', '999G999G999D999', "NLS_NUMERIC_CHARACTERS = ',.'") # => #<OraNumber:123456.789>
|
803
|
+
*
|
804
|
+
* @param [String, Numeric] expr
|
805
|
+
* @param [String] fmt
|
806
|
+
* @param [String] nlsparam
|
807
|
+
*/
|
682
808
|
static VALUE onum_initialize(int argc, VALUE *argv, VALUE self)
|
683
809
|
{
|
684
810
|
OCIError *errhp = oci8_errhp;
|
@@ -696,6 +822,17 @@ static VALUE onum_initialize(int argc, VALUE *argv, VALUE self)
|
|
696
822
|
return Qnil;
|
697
823
|
}
|
698
824
|
|
825
|
+
/*
|
826
|
+
* call-seq:
|
827
|
+
* initialize_copy(obj)
|
828
|
+
*
|
829
|
+
* Replaces <i>self</i> with <i>obj</i>. <code>Object#clone</code> and <code>Object#dup</code>
|
830
|
+
* call this method to copy data unknown by the ruby interpreter.
|
831
|
+
*
|
832
|
+
* @param [OraNumber] obj
|
833
|
+
*
|
834
|
+
* @private
|
835
|
+
*/
|
699
836
|
static VALUE onum_initialize_copy(VALUE lhs, VALUE rhs)
|
700
837
|
{
|
701
838
|
if (!RTEST(rb_obj_is_instance_of(rhs, CLASS_OF(lhs)))) {
|
@@ -706,6 +843,9 @@ static VALUE onum_initialize_copy(VALUE lhs, VALUE rhs)
|
|
706
843
|
return lhs;
|
707
844
|
}
|
708
845
|
|
846
|
+
/*
|
847
|
+
* @private
|
848
|
+
*/
|
709
849
|
static VALUE onum_coerce(VALUE self, VALUE other)
|
710
850
|
{
|
711
851
|
signed long sl;
|
@@ -733,10 +873,12 @@ static VALUE onum_coerce(VALUE self, VALUE other)
|
|
733
873
|
}
|
734
874
|
|
735
875
|
/*
|
736
|
-
*
|
737
|
-
*
|
876
|
+
* Returns a negated value of <i>self</i>
|
877
|
+
*
|
878
|
+
* @example
|
879
|
+
* -OraNumber(2) # => #<OraNumber:-2>
|
738
880
|
*
|
739
|
-
*
|
881
|
+
* @return [OraNumber]
|
740
882
|
*/
|
741
883
|
static VALUE onum_neg(VALUE self)
|
742
884
|
{
|
@@ -747,12 +889,20 @@ static VALUE onum_neg(VALUE self)
|
|
747
889
|
return oci8_make_ocinumber(&r, errhp);
|
748
890
|
}
|
749
891
|
|
750
|
-
|
751
892
|
/*
|
752
893
|
* call-seq:
|
753
|
-
*
|
894
|
+
* self + other
|
895
|
+
*
|
896
|
+
* Returns the sum of <i>self</i> and <i>other</i>.
|
897
|
+
* When <i>other</i>'s class is Integer, it returns an OraNumber value.
|
898
|
+
* Otherwise, it returns a value same with <i>other</i>'s class.
|
754
899
|
*
|
755
|
-
*
|
900
|
+
* @example
|
901
|
+
* OraNumber(2) + 3 # => #<OraNumber:5>
|
902
|
+
* OraNumber(2) + 1.5 # => 3.5 (Float)
|
903
|
+
*
|
904
|
+
* @param [Numeric] other
|
905
|
+
* @return [Numeric]
|
756
906
|
*/
|
757
907
|
static VALUE onum_add(VALUE lhs, VALUE rhs)
|
758
908
|
{
|
@@ -783,10 +933,18 @@ static VALUE onum_add(VALUE lhs, VALUE rhs)
|
|
783
933
|
|
784
934
|
/*
|
785
935
|
* call-seq:
|
786
|
-
*
|
787
|
-
*
|
936
|
+
* self - other
|
937
|
+
*
|
938
|
+
* Returns the difference of <i>self</i> and <i>other</i>.
|
939
|
+
* When <i>other</i>'s class is Integer, it returns an OraNumber value.
|
940
|
+
* Otherwise, it returns a value same with <i>other</i>'s class.
|
788
941
|
*
|
789
|
-
*
|
942
|
+
* @example
|
943
|
+
* OraNumber(2) - 3 # => #<OraNumber:-1>
|
944
|
+
* OraNumber(2) - 1.5 # => 0.5 (Float)
|
945
|
+
*
|
946
|
+
* @param [Numeric] other
|
947
|
+
* @return [Numeric]
|
790
948
|
*/
|
791
949
|
static VALUE onum_sub(VALUE lhs, VALUE rhs)
|
792
950
|
{
|
@@ -817,9 +975,18 @@ static VALUE onum_sub(VALUE lhs, VALUE rhs)
|
|
817
975
|
|
818
976
|
/*
|
819
977
|
* call-seq:
|
820
|
-
*
|
978
|
+
* self * other
|
979
|
+
*
|
980
|
+
* Returns the product of <i>self</i> and <i>other</i>.
|
981
|
+
* When <i>other</i>'s class is Integer, it returns an OraNumber value.
|
982
|
+
* Otherwise, it returns a value same with <i>other</i>'s class.
|
983
|
+
*
|
984
|
+
* @example
|
985
|
+
* OraNumber(2) * 3 # => #<OraNumber:6>
|
986
|
+
* OraNumber(2) * 1.5 # => 3.0 (Float)
|
821
987
|
*
|
822
|
-
*
|
988
|
+
* @param [Numeric] other
|
989
|
+
* @return [Numeric]
|
823
990
|
*/
|
824
991
|
static VALUE onum_mul(VALUE lhs, VALUE rhs)
|
825
992
|
{
|
@@ -850,10 +1017,18 @@ static VALUE onum_mul(VALUE lhs, VALUE rhs)
|
|
850
1017
|
|
851
1018
|
/*
|
852
1019
|
* call-seq:
|
853
|
-
*
|
854
|
-
*
|
1020
|
+
* self / other
|
1021
|
+
*
|
1022
|
+
* Returns the result of dividing <i>self</i> by <i>other</i>.
|
1023
|
+
* When <i>other</i>'s class is Integer, it returns an OraNumber value.
|
1024
|
+
* Otherwise, it returns a value same with <i>other</i>'s class.
|
1025
|
+
*
|
1026
|
+
* @example
|
1027
|
+
* OraNumber(2) / 3 # => #<OraNumber:0.6666666666666666666666666666666666666667>
|
1028
|
+
* OraNumber(2) / 1.5 # => 1.3333333333333333 (Float)
|
855
1029
|
*
|
856
|
-
*
|
1030
|
+
* @param [Numeric] other
|
1031
|
+
* @return [Numeric]
|
857
1032
|
*/
|
858
1033
|
static VALUE onum_div(VALUE lhs, VALUE rhs)
|
859
1034
|
{
|
@@ -892,9 +1067,17 @@ static VALUE onum_div(VALUE lhs, VALUE rhs)
|
|
892
1067
|
|
893
1068
|
/*
|
894
1069
|
* call-seq:
|
895
|
-
*
|
1070
|
+
* self % other
|
896
1071
|
*
|
897
|
-
* Returns the modulo after division of <i>
|
1072
|
+
* Returns the modulo after division of <i>self</i> by <i>other</i>.
|
1073
|
+
*
|
1074
|
+
* @example
|
1075
|
+
* OraNumber(13) % 5 # => #<OraNumber:3>
|
1076
|
+
*
|
1077
|
+
* @param [Numeric] other
|
1078
|
+
* @return [OraNumber]
|
1079
|
+
*
|
1080
|
+
* @raise [ZeroDivisionError] when <i>other</i> is zero.
|
898
1081
|
*/
|
899
1082
|
static VALUE onum_mod(VALUE lhs, VALUE rhs)
|
900
1083
|
{
|
@@ -917,9 +1100,16 @@ static VALUE onum_mod(VALUE lhs, VALUE rhs)
|
|
917
1100
|
|
918
1101
|
/*
|
919
1102
|
* call-seq:
|
920
|
-
*
|
1103
|
+
* self ** other
|
1104
|
+
*
|
1105
|
+
* Raises <i>self</i> to the power of <i>other</i>.
|
921
1106
|
*
|
922
|
-
*
|
1107
|
+
* @example
|
1108
|
+
* OraNumber(2) ** 2 # => #<OraNumber:4>
|
1109
|
+
* OraNumber(2) ** 2.5 # => #<OraNumber:5.65685424949238019520675489683879231435>
|
1110
|
+
*
|
1111
|
+
* @param [Numeric] other
|
1112
|
+
* @return [OraNumber]
|
923
1113
|
*/
|
924
1114
|
static VALUE onum_power(VALUE lhs, VALUE rhs)
|
925
1115
|
{
|
@@ -940,11 +1130,19 @@ static VALUE onum_power(VALUE lhs, VALUE rhs)
|
|
940
1130
|
|
941
1131
|
/*
|
942
1132
|
* call-seq:
|
943
|
-
*
|
1133
|
+
* self <=> other
|
944
1134
|
*
|
945
|
-
* Returns -1, 0, or +1 depending on whether <i>
|
1135
|
+
* Returns -1, 0, or +1 depending on whether <i>self</i> is less than,
|
946
1136
|
* equal to, or greater than <i>other</i>. This is the basis for the
|
947
1137
|
* tests in <code>Comparable</code>.
|
1138
|
+
*
|
1139
|
+
* @example
|
1140
|
+
* OraNumber(5) <=> 3 # => 1
|
1141
|
+
* OraNumber(4) <=> 4 # => 0
|
1142
|
+
* OraNumber(2) <=> 2.5 # => 1
|
1143
|
+
*
|
1144
|
+
* @param [Numeric] other
|
1145
|
+
* @return [-1, 0 or +1]
|
948
1146
|
*/
|
949
1147
|
static VALUE onum_cmp(VALUE lhs, VALUE rhs)
|
950
1148
|
{
|
@@ -967,10 +1165,14 @@ static VALUE onum_cmp(VALUE lhs, VALUE rhs)
|
|
967
1165
|
}
|
968
1166
|
|
969
1167
|
/*
|
970
|
-
*
|
971
|
-
* onum.floor -> integer
|
1168
|
+
* Returns the largest <code>Integer</code> less than or equal to <i>self</i>.
|
972
1169
|
*
|
973
|
-
*
|
1170
|
+
* @example
|
1171
|
+
* OraNumber(11.1).floor # => 11
|
1172
|
+
* OraNumber(25.8).floor # => 25
|
1173
|
+
* OraNumber(-25.8).floor # => -26
|
1174
|
+
*
|
1175
|
+
* @return [Integer]
|
974
1176
|
*/
|
975
1177
|
static VALUE onum_floor(VALUE self)
|
976
1178
|
{
|
@@ -982,11 +1184,14 @@ static VALUE onum_floor(VALUE self)
|
|
982
1184
|
}
|
983
1185
|
|
984
1186
|
/*
|
985
|
-
*
|
986
|
-
* onum.ceil -> integer
|
1187
|
+
* Returns the smallest <code>Integer</code> greater than or equal to <i>self</i>.
|
987
1188
|
*
|
988
|
-
*
|
989
|
-
*
|
1189
|
+
* @example
|
1190
|
+
* OraNumber(11.1).ceil # => 12
|
1191
|
+
* OraNumber(25.8).ceil # => 26
|
1192
|
+
* OraNumber(-25.8).ceil # => -25
|
1193
|
+
*
|
1194
|
+
* @return [Integer]
|
990
1195
|
*/
|
991
1196
|
static VALUE onum_ceil(VALUE self)
|
992
1197
|
{
|
@@ -998,16 +1203,30 @@ static VALUE onum_ceil(VALUE self)
|
|
998
1203
|
}
|
999
1204
|
|
1000
1205
|
/*
|
1001
|
-
*
|
1002
|
-
* onum.round -> integer
|
1003
|
-
* onum.round(decplace) -> oranumber
|
1206
|
+
* @overload round
|
1004
1207
|
*
|
1005
|
-
*
|
1006
|
-
* Rounds <i>onum</i> to a specified decimal place <i>decplace</i> when one argument.
|
1208
|
+
* Rounds <i>self</i> to the nearest <code>Integer</code>.
|
1007
1209
|
*
|
1008
|
-
*
|
1009
|
-
*
|
1010
|
-
*
|
1210
|
+
* @example
|
1211
|
+
* OraNumber(1.49).round # => 1
|
1212
|
+
* OraNumber(1.5).round # => 2
|
1213
|
+
* OraNumber(-1.49).round # => -1
|
1214
|
+
* OraNumber(-1.5).round # => -2
|
1215
|
+
*
|
1216
|
+
* @return [Integer]
|
1217
|
+
*
|
1218
|
+
* @overload round(decplace)
|
1219
|
+
*
|
1220
|
+
* Rounds <i>onum</i> to a specified decimal place <i>decplace</i>.
|
1221
|
+
*
|
1222
|
+
* @example
|
1223
|
+
* OraNumber(123.456).round(2) # => #<OraNumber:123.46>
|
1224
|
+
* OraNumber(123.456).round(1) # => #<OraNumber:123.5>
|
1225
|
+
* OraNumber(123.456).round(0) # => #<OraNumber:123>
|
1226
|
+
* OraNumber(123.456).round(-1) # => #<OraNumber:120>
|
1227
|
+
*
|
1228
|
+
* @param [Integer]
|
1229
|
+
* @return [OraNumber]
|
1011
1230
|
*/
|
1012
1231
|
static VALUE onum_round(int argc, VALUE *argv, VALUE self)
|
1013
1232
|
{
|
@@ -1026,11 +1245,24 @@ static VALUE onum_round(int argc, VALUE *argv, VALUE self)
|
|
1026
1245
|
|
1027
1246
|
/*
|
1028
1247
|
* call-seq:
|
1029
|
-
*
|
1030
|
-
* onum.truncate(decplace) -> oranumber
|
1248
|
+
* truncate(decplace = 0)
|
1031
1249
|
*
|
1032
|
-
* Truncates <i>
|
1033
|
-
*
|
1250
|
+
* Truncates <i>self</i> to a specified decimal place <i>decplace</i>.
|
1251
|
+
*
|
1252
|
+
* @example
|
1253
|
+
* OraNumber(123.456).truncate # => #<OraNumber:123>
|
1254
|
+
* OraNumber(123.456).truncate(1) # => #<OraNumber:123.4>
|
1255
|
+
* OraNumber(123.456).truncate(2) # => #<OraNumber:123.45>
|
1256
|
+
* OraNumber(123.456).truncate(-1) # => #<OraNumber:120>
|
1257
|
+
*
|
1258
|
+
* OraNumber(-123.456).truncate # => #<OraNumber:-123>
|
1259
|
+
* OraNumber(-123.456).truncate(1) # => #<OraNumber:-123.4>
|
1260
|
+
* OraNumber(-123.456).truncate(2) # => #<OraNumber:-123.45>
|
1261
|
+
* OraNumber(-123.456).truncate(-1) # => #<OraNumber:-120>
|
1262
|
+
*
|
1263
|
+
* @param [Integer]
|
1264
|
+
* @return [OraNumber]
|
1265
|
+
* @todo returns {Integer} when <i>decplace</i> is not specified.
|
1034
1266
|
*/
|
1035
1267
|
static VALUE onum_trunc(int argc, VALUE *argv, VALUE self)
|
1036
1268
|
{
|
@@ -1045,14 +1277,17 @@ static VALUE onum_trunc(int argc, VALUE *argv, VALUE self)
|
|
1045
1277
|
|
1046
1278
|
/*
|
1047
1279
|
* call-seq:
|
1048
|
-
*
|
1280
|
+
* round_prec(digits)
|
1049
1281
|
*
|
1050
|
-
* Rounds <i>
|
1282
|
+
* Rounds <i>self</i> to a specified number of decimal digits.
|
1051
1283
|
* This method is available on Oracle 8.1 client or upper.
|
1052
1284
|
*
|
1053
|
-
*
|
1054
|
-
*
|
1055
|
-
*
|
1285
|
+
* @example
|
1286
|
+
* OraNumber(1.234).round_prec(2) # => #<OraNumber:1.2>
|
1287
|
+
* OraNumber(12.34).round_prec(2) # => #<OraNumber:12>
|
1288
|
+
* OraNumber(123.4).round_prec(2) # => #<OraNumber:120>
|
1289
|
+
*
|
1290
|
+
* @return [OraNumber]
|
1056
1291
|
*/
|
1057
1292
|
static VALUE onum_round_prec(VALUE self, VALUE ndigs)
|
1058
1293
|
{
|
@@ -1065,11 +1300,20 @@ static VALUE onum_round_prec(VALUE self, VALUE ndigs)
|
|
1065
1300
|
|
1066
1301
|
/*
|
1067
1302
|
* call-seq:
|
1068
|
-
* onum.to_char(fmt = nil,
|
1303
|
+
* onum.to_char(fmt = nil, nlsparam = nil)
|
1069
1304
|
*
|
1070
1305
|
* Returns a string containing a representation of self.
|
1071
|
-
* <i>fmt</i> and <i>
|
1072
|
-
*
|
1306
|
+
* <i>fmt</i> and <i>nlsparam</i> are used as
|
1307
|
+
* {http://docs.oracle.com/cd/E11882_01/server.112/e17118/functions201.htm Oracle SQL function TO_CHAR(number)}
|
1308
|
+
* does.
|
1309
|
+
*
|
1310
|
+
* @example
|
1311
|
+
* OraNumber(123456.789).to_char('FM999,999,999.999') # => "123,456.789"
|
1312
|
+
* OraNumber(123456.789).to_char('FM999G999G999D999', "NLS_NUMERIC_CHARACTERS = ',.'") # => "123.456,789"
|
1313
|
+
*
|
1314
|
+
* @param [String] fmt
|
1315
|
+
* @param [String] nlsparam
|
1316
|
+
* @return [String]
|
1073
1317
|
*/
|
1074
1318
|
static VALUE onum_to_char(int argc, VALUE *argv, VALUE self)
|
1075
1319
|
{
|
@@ -1121,10 +1365,11 @@ static VALUE onum_to_char(int argc, VALUE *argv, VALUE self)
|
|
1121
1365
|
}
|
1122
1366
|
|
1123
1367
|
/*
|
1124
|
-
* call-seq:
|
1125
|
-
* onum.to_s -> string
|
1126
|
-
*
|
1127
1368
|
* Returns a string containing a representation of self.
|
1369
|
+
*
|
1370
|
+
* @return [String]
|
1371
|
+
*
|
1372
|
+
* @see #to_char
|
1128
1373
|
*/
|
1129
1374
|
static VALUE onum_to_s(VALUE self)
|
1130
1375
|
{
|
@@ -1132,10 +1377,9 @@ static VALUE onum_to_s(VALUE self)
|
|
1132
1377
|
}
|
1133
1378
|
|
1134
1379
|
/*
|
1135
|
-
*
|
1136
|
-
* onum.to_i -> integer
|
1380
|
+
* Returns <i>self</i> truncated to an <code>Integer</code>.
|
1137
1381
|
*
|
1138
|
-
*
|
1382
|
+
* @return [Integer]
|
1139
1383
|
*/
|
1140
1384
|
static VALUE onum_to_i(VALUE self)
|
1141
1385
|
{
|
@@ -1147,11 +1391,14 @@ static VALUE onum_to_i(VALUE self)
|
|
1147
1391
|
}
|
1148
1392
|
|
1149
1393
|
/*
|
1150
|
-
*
|
1151
|
-
* onum.to_f -> float
|
1394
|
+
* Converts <i>self</i> to <code>Float</code>.
|
1152
1395
|
*
|
1153
|
-
*
|
1396
|
+
* When {OCI8.properties OCI8.properties [:float_conversion_type\]}
|
1397
|
+
* is <code>:ruby</code>, <i>self</I> is converted by <code>self.to_s.to_f</code>.
|
1398
|
+
* When it is <code>:oracle</code>, <i>self</I> is converted by the Oracle
|
1399
|
+
* OCI function OCINumberToReal().
|
1154
1400
|
*
|
1401
|
+
* @return [Float]
|
1155
1402
|
*/
|
1156
1403
|
static VALUE onum_to_f(VALUE self)
|
1157
1404
|
{
|
@@ -1159,11 +1406,9 @@ static VALUE onum_to_f(VALUE self)
|
|
1159
1406
|
}
|
1160
1407
|
|
1161
1408
|
/*
|
1162
|
-
*
|
1163
|
-
* onum.to_r -> rational
|
1164
|
-
*
|
1165
|
-
* Return the value as a <code>Rational</code>.
|
1409
|
+
* Returns <i>self</i> as a <code>Rational</code>.
|
1166
1410
|
*
|
1411
|
+
* @return [Rational]
|
1167
1412
|
*/
|
1168
1413
|
static VALUE onum_to_r(VALUE self)
|
1169
1414
|
{
|
@@ -1202,11 +1447,9 @@ static VALUE onum_to_r(VALUE self)
|
|
1202
1447
|
}
|
1203
1448
|
|
1204
1449
|
/*
|
1205
|
-
*
|
1206
|
-
* onum.to_d -> bigdecimal
|
1207
|
-
*
|
1208
|
-
* Return the value as a <code>BigDecimal</code>.
|
1450
|
+
* Returns <i>self</i> as a <code>BigDecimal</code>.
|
1209
1451
|
*
|
1452
|
+
* @return [BigDecimal]
|
1210
1453
|
*/
|
1211
1454
|
static VALUE onum_to_d(VALUE self)
|
1212
1455
|
{
|
@@ -1230,13 +1473,14 @@ static VALUE onum_to_d_real(OCINumber *num, OCIError *errhp)
|
|
1230
1473
|
}
|
1231
1474
|
|
1232
1475
|
/*
|
1233
|
-
*
|
1234
|
-
* onum.has_decimal_part? -> true or false
|
1235
|
-
*
|
1236
|
-
* Returns +true+ if <i>self</i> has a decimal part.
|
1476
|
+
* Returns <code>true</code> if <i>self</i> has a decimal part.
|
1237
1477
|
*
|
1478
|
+
* @example
|
1238
1479
|
* OraNumber(10).has_decimal_part? # => false
|
1239
1480
|
* OraNumber(10.1).has_decimal_part? # => true
|
1481
|
+
*
|
1482
|
+
* @return [true or false]
|
1483
|
+
* @since 2.0.5
|
1240
1484
|
*/
|
1241
1485
|
static VALUE onum_has_decimal_part_p(VALUE self)
|
1242
1486
|
{
|
@@ -1248,11 +1492,9 @@ static VALUE onum_has_decimal_part_p(VALUE self)
|
|
1248
1492
|
}
|
1249
1493
|
|
1250
1494
|
/*
|
1251
|
-
* call-seq:
|
1252
|
-
* onum.to_onum -> oranumber
|
1253
|
-
*
|
1254
1495
|
* Returns self.
|
1255
1496
|
*
|
1497
|
+
* @return [OraNumber]
|
1256
1498
|
*/
|
1257
1499
|
static VALUE onum_to_onum(VALUE self)
|
1258
1500
|
{
|
@@ -1260,11 +1502,9 @@ static VALUE onum_to_onum(VALUE self)
|
|
1260
1502
|
}
|
1261
1503
|
|
1262
1504
|
/*
|
1263
|
-
*
|
1264
|
-
* onum.zero? -> true or false
|
1265
|
-
*
|
1266
|
-
* Returns <code>true</code> if <i>onum</i> is zero.
|
1505
|
+
* Returns <code>true</code> if <i>self</i> is zero.
|
1267
1506
|
*
|
1507
|
+
* @return [true or false]
|
1268
1508
|
*/
|
1269
1509
|
static VALUE onum_zero_p(VALUE self)
|
1270
1510
|
{
|
@@ -1276,11 +1516,9 @@ static VALUE onum_zero_p(VALUE self)
|
|
1276
1516
|
}
|
1277
1517
|
|
1278
1518
|
/*
|
1279
|
-
*
|
1280
|
-
* onum.abs -> oranumber
|
1281
|
-
*
|
1282
|
-
* Returns the absolute value of <i>onum</i>.
|
1519
|
+
* Returns the absolute value of <i>self</i>.
|
1283
1520
|
*
|
1521
|
+
* @return [OraNumber]
|
1284
1522
|
*/
|
1285
1523
|
static VALUE onum_abs(VALUE self)
|
1286
1524
|
{
|
@@ -1293,10 +1531,16 @@ static VALUE onum_abs(VALUE self)
|
|
1293
1531
|
|
1294
1532
|
/*
|
1295
1533
|
* call-seq:
|
1296
|
-
*
|
1534
|
+
* shift(ndigits)
|
1297
1535
|
*
|
1298
|
-
* Returns <i>
|
1536
|
+
* Returns <i>self</i> shifted by <i>ndigits</i>
|
1299
1537
|
* This method is available on Oracle 8.1 client or upper.
|
1538
|
+
*
|
1539
|
+
* @example
|
1540
|
+
* OraNumber(123).shift(3) # => #<OraNumber:123000>
|
1541
|
+
* OraNumber(123).shift(-3) # => #<OraNumber:0.123>
|
1542
|
+
*
|
1543
|
+
* @return [OraNumber]
|
1300
1544
|
*/
|
1301
1545
|
static VALUE onum_shift(VALUE self, VALUE exp)
|
1302
1546
|
{
|
@@ -1308,15 +1552,16 @@ static VALUE onum_shift(VALUE self, VALUE exp)
|
|
1308
1552
|
}
|
1309
1553
|
|
1310
1554
|
/*
|
1311
|
-
*
|
1312
|
-
*
|
1555
|
+
* Returns internal representation whose format is same with the return value of
|
1556
|
+
* {http://docs.oracle.com/cd/E11882_01/server.112/e17118/functions055.htm Oracle SQL function DUMP}.
|
1313
1557
|
*
|
1314
|
-
*
|
1315
|
-
*
|
1558
|
+
* @example
|
1559
|
+
* OraNumber.new(100).dump #=> "Typ=2 Len=2: 194,2"
|
1560
|
+
* OraNumber.new(123).dump #=> "Typ=2 Len=3: 194,2,24"
|
1561
|
+
* OraNumber.new(0.1).dump #=> "Typ=2 Len=2: 192,11"
|
1316
1562
|
*
|
1317
|
-
*
|
1318
|
-
*
|
1319
|
-
* OraNumber.new(0.1).dump #=> "Typ=2 Len=2: 192,11"
|
1563
|
+
* @return [String]
|
1564
|
+
* @since 2.0.4
|
1320
1565
|
*/
|
1321
1566
|
static VALUE onum_dump(VALUE self)
|
1322
1567
|
{
|
@@ -1325,6 +1570,9 @@ static VALUE onum_dump(VALUE self)
|
|
1325
1570
|
return rb_usascii_str_new(buf, rv);
|
1326
1571
|
}
|
1327
1572
|
|
1573
|
+
/*
|
1574
|
+
* @private
|
1575
|
+
*/
|
1328
1576
|
static VALUE onum_hash(VALUE self)
|
1329
1577
|
{
|
1330
1578
|
char *c = DATA_PTR(self);
|
@@ -1342,6 +1590,9 @@ static VALUE onum_hash(VALUE self)
|
|
1342
1590
|
return INT2FIX(hash);
|
1343
1591
|
}
|
1344
1592
|
|
1593
|
+
/*
|
1594
|
+
* @private
|
1595
|
+
*/
|
1345
1596
|
static VALUE onum_inspect(VALUE self)
|
1346
1597
|
{
|
1347
1598
|
const char *name = rb_class2name(CLASS_OF(self));
|
@@ -1356,9 +1607,13 @@ static VALUE onum_inspect(VALUE self)
|
|
1356
1607
|
|
1357
1608
|
/*
|
1358
1609
|
* call-seq:
|
1359
|
-
*
|
1610
|
+
* _dump
|
1360
1611
|
*
|
1361
|
-
*
|
1612
|
+
* Serializes <i>self</i>.
|
1613
|
+
* This method is called by Marshal.dump().
|
1614
|
+
*
|
1615
|
+
* @return [String] a byte stream
|
1616
|
+
* @see OraNumber._load
|
1362
1617
|
*/
|
1363
1618
|
static VALUE onum__dump(int argc, VALUE *argv, VALUE self)
|
1364
1619
|
{
|
@@ -1372,9 +1627,14 @@ static VALUE onum__dump(int argc, VALUE *argv, VALUE self)
|
|
1372
1627
|
|
1373
1628
|
/*
|
1374
1629
|
* call-seq:
|
1375
|
-
*
|
1630
|
+
* _load(bytes)
|
1631
|
+
*
|
1632
|
+
* Restores a byte stream serialized by {OraNumber#_dump}.
|
1633
|
+
* This method is called by Marshal.load() to deserialize a byte stream
|
1634
|
+
* created by Marshal.dump().
|
1376
1635
|
*
|
1377
|
-
*
|
1636
|
+
* @param [String] bytes a byte stream
|
1637
|
+
* @return [OraNumber] an deserialized object
|
1378
1638
|
*/
|
1379
1639
|
static VALUE
|
1380
1640
|
onum_s_load(VALUE klass, VALUE str)
|
@@ -1395,8 +1655,17 @@ onum_s_load(VALUE klass, VALUE str)
|
|
1395
1655
|
}
|
1396
1656
|
|
1397
1657
|
/*
|
1398
|
-
*
|
1658
|
+
* Document-class: OCI8::BindType::OraNumber
|
1659
|
+
*/
|
1660
|
+
|
1661
|
+
/*
|
1662
|
+
* Document-class: OCI8::BindType::Integer
|
1663
|
+
*/
|
1664
|
+
|
1665
|
+
/*
|
1666
|
+
* Document-class: OCI8::BindType::Float
|
1399
1667
|
*/
|
1668
|
+
|
1400
1669
|
static VALUE bind_ocinumber_get(oci8_bind_t *obind, void *data, void *null_struct)
|
1401
1670
|
{
|
1402
1671
|
return oci8_make_ocinumber((OCINumber*)data, oci8_errhp);
|
@@ -1555,10 +1824,10 @@ Init_oci_number(VALUE cOCI8, OCIError *errhp)
|
|
1555
1824
|
rb_define_alloc_func(cOCINumber, onum_s_alloc);
|
1556
1825
|
|
1557
1826
|
/* methods of OCI::Number */
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1561
|
-
|
1827
|
+
rb_define_global_function("OraNumber", onum_f_new, -1);
|
1828
|
+
rb_define_method(cOCINumber, "initialize", onum_initialize, -1);
|
1829
|
+
rb_define_method(cOCINumber, "initialize_copy", onum_initialize_copy, 1);
|
1830
|
+
rb_define_method(cOCINumber, "coerce", onum_coerce, 1);
|
1562
1831
|
|
1563
1832
|
rb_include_module(cOCINumber, rb_mComparable);
|
1564
1833
|
|
@@ -1584,15 +1853,15 @@ Init_oci_number(VALUE cOCI8, OCIError *errhp)
|
|
1584
1853
|
rb_define_method(cOCINumber, "to_r", onum_to_r, 0);
|
1585
1854
|
rb_define_method(cOCINumber, "to_d", onum_to_d, 0);
|
1586
1855
|
rb_define_method(cOCINumber, "has_decimal_part?", onum_has_decimal_part_p, 0);
|
1587
|
-
|
1856
|
+
rb_define_method(cOCINumber, "to_onum", onum_to_onum, 0);
|
1588
1857
|
|
1589
1858
|
rb_define_method(cOCINumber, "zero?", onum_zero_p, 0);
|
1590
1859
|
rb_define_method(cOCINumber, "abs", onum_abs, 0);
|
1591
1860
|
rb_define_method(cOCINumber, "shift", onum_shift, 1);
|
1592
1861
|
rb_define_method(cOCINumber, "dump", onum_dump, 0);
|
1593
1862
|
|
1594
|
-
|
1595
|
-
|
1863
|
+
rb_define_method(cOCINumber, "hash", onum_hash, 0);
|
1864
|
+
rb_define_method(cOCINumber, "inspect", onum_inspect, 0);
|
1596
1865
|
|
1597
1866
|
/* methods for marshaling */
|
1598
1867
|
rb_define_method(cOCINumber, "_dump", onum__dump, -1);
|
@@ -1601,8 +1870,22 @@ Init_oci_number(VALUE cOCI8, OCIError *errhp)
|
|
1601
1870
|
oci8_define_bind_class("OraNumber", &bind_ocinumber_vtable);
|
1602
1871
|
oci8_define_bind_class("Integer", &bind_integer_vtable);
|
1603
1872
|
oci8_define_bind_class("Float", &bind_float_vtable);
|
1873
|
+
|
1874
|
+
#if 0 /* for rdoc/yard */
|
1875
|
+
oci8_cOCIHandle = rb_define_class("OCIHandle", rb_cObject);
|
1876
|
+
cOCI8 = rb_define_class("OCI8", oci8_cOCIHandle);
|
1877
|
+
mOCI8BindType = rb_define_module_under(cOCI8, "BindType");
|
1878
|
+
cOCI8BindTypeBase = rb_define_class_under(mOCI8BindType, "Base", oci8_cOCIHandle);
|
1879
|
+
|
1880
|
+
dummy1 = rb_define_class_under(mOCI8BindType, "OraNumber", cOCI8BindTypeBase);
|
1881
|
+
dummy2 = rb_define_class_under(mOCI8BindType, "Integer", cOCI8BindTypeBase);
|
1882
|
+
dummy3 = rb_define_class_under(mOCI8BindType, "Float", cOCI8BindTypeBase);
|
1883
|
+
#endif
|
1604
1884
|
}
|
1605
1885
|
|
1886
|
+
/*
|
1887
|
+
* OraNumber (ruby object) -> OCINumber (C datatype)
|
1888
|
+
*/
|
1606
1889
|
OCINumber *oci8_get_ocinumber(VALUE num)
|
1607
1890
|
{
|
1608
1891
|
if (!rb_obj_is_kind_of(num, cOCINumber)) {
|