[ruby-oci8-commit] [253] trunk/ruby-oci8: * ext/oci8/ocinumber.c, lib/oci8/compat.rb, lib/oci8 /object.rb
nobody at rubyforge.org
nobody at rubyforge.org
Wed Mar 19 10:02:01 EDT 2008
Revision: 253
Author: kubo
Date: 2008-03-19 10:02:00 -0400 (Wed, 19 Mar 2008)
Log Message:
-----------
* ext/oci8/ocinumber.c, lib/oci8/compat.rb, lib/oci8/object.rb
lib/oci8/oci8.rb, test/test_oci8.rb:
1. OCINumber, which is a new object in 2.0, become OraNumber.
This means OraNumber become a true numeric class.
2. Rdoc comments in ocinumber.c are fixed.
Modified Paths:
--------------
trunk/ruby-oci8/ChangeLog
trunk/ruby-oci8/ext/oci8/ocinumber.c
trunk/ruby-oci8/lib/oci8/compat.rb
trunk/ruby-oci8/lib/oci8/object.rb
trunk/ruby-oci8/lib/oci8/oci8.rb
trunk/ruby-oci8/test/test_oci8.rb
Modified: trunk/ruby-oci8/ChangeLog
===================================================================
--- trunk/ruby-oci8/ChangeLog 2008-03-08 03:10:53 UTC (rev 252)
+++ trunk/ruby-oci8/ChangeLog 2008-03-19 14:02:00 UTC (rev 253)
@@ -1,3 +1,10 @@
+2008-03-19 KUBO Takehiro <kubo at jiubao.org>
+ * ext/oci8/ocinumber.c, lib/oci8/compat.rb, lib/oci8/object.rb
+ lib/oci8/oci8.rb, test/test_oci8.rb:
+ 1. OCINumber, which is a new object in 2.0, become OraNumber.
+ This means OraNumber become a true numeric class.
+ 2. Rdoc comments in ocinumber.c are fixed.
+
2008-03-08 KUBO Takehiro <kubo at jiubao.org>
* ext/oci8/extconf.rb, ext/oci8/oci8lib.c, ext/oci8/rowid.c:
rowid.c is deleted. OCIRowid is no longer in use.
Modified: trunk/ruby-oci8/ext/oci8/ocinumber.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/ocinumber.c 2008-03-08 03:10:53 UTC (rev 252)
+++ trunk/ruby-oci8/ext/oci8/ocinumber.c 2008-03-19 14:02:00 UTC (rev 253)
@@ -197,7 +197,7 @@
/*
* call-seq:
- * OCI8::Math.atan2(y, x) => ocinumber
+ * OCI8::Math.atan2(y, x) -> oranumber
*
* Computes the arc tangent given <i>y</i> and <i>x</i>. Returns
* -PI..PI.
@@ -232,7 +232,7 @@
/*
* call-seq:
- * OCI8::Math.cos(x) => ocinumber
+ * OCI8::Math.cos(x) -> oranumber
*
* Computes the cosine of <i>x</i> (expressed in radians). Returns
* -1..1.
@@ -248,7 +248,7 @@
/*
* call-seq:
- * OCI8::Math.sin(x) => ocinumber
+ * OCI8::Math.sin(x) -> oranumber
*
* Computes the sine of <i>x</i> (expressed in radians). Returns
* -1..1.
@@ -264,7 +264,7 @@
/*
* call-seq:
- * OCI8::Math.tan(x) => ocinumber
+ * OCI8::Math.tan(x) -> oranumber
*
* Returns the tangent of <i>x</i> (expressed in radians).
*/
@@ -279,7 +279,7 @@
/*
* call-seq:
- * OCI8::Math.acos(x) => ocinumber
+ * OCI8::Math.acos(x) -> oranumber
*
* Computes the arc cosine of <i>x</i>. Returns 0..PI.
*/
@@ -305,7 +305,7 @@
/*
* call-seq:
- * OCI8::Math.asin(x) => ocinumber
+ * OCI8::Math.asin(x) -> oranumber
*
* Computes the arc sine of <i>x</i>. Returns 0..PI.
*/
@@ -331,7 +331,7 @@
/*
* call-seq:
- * OCI8::Math.atan(x) => ocinumber
+ * OCI8::Math.atan(x) -> oranumber
*
* Computes the arc tangent of <i>x</i>. Returns -{PI/2} .. {PI/2}.
*/
@@ -346,7 +346,7 @@
/*
* call-seq:
- * OCI8::Math.cosh(x) => ocinumber
+ * OCI8::Math.cosh(x) -> oranumber
*
* Computes the hyperbolic cosine of <i>x</i> (expressed in radians).
*/
@@ -361,7 +361,7 @@
/*
* call-seq:
- * OCI8::Math.sinh(x) => ocinumber
+ * OCI8::Math.sinh(x) -> oranumber
*
* Computes the hyperbolic sine of <i>x</i> (expressed in
* radians).
@@ -377,7 +377,7 @@
/*
* call-seq:
- * OCI8::Math.tanh() => ocinumber
+ * OCI8::Math.tanh() -> oranumber
*
* Computes the hyperbolic tangent of <i>x</i> (expressed in
* radians).
@@ -393,7 +393,7 @@
/*
* call-seq:
- * OCI8::Math.exp(x) => ocinumber
+ * OCI8::Math.exp(x) -> oranumber
*
* Returns e**x.
*/
@@ -408,8 +408,8 @@
/*
* call-seq:
- * OCI8::Math.log(numeric) => ocinumber
- * OCI8::Math.log(numeric, base_num) => ocinumber
+ * OCI8::Math.log(numeric) -> oranumber
+ * OCI8::Math.log(numeric, base_num) -> oranumber
*
* Returns the natural logarithm of <i>numeric</i> for one argument.
* Returns the base <i>base_num</i> logarithm of <i>numeric</i> for two arguments.
@@ -444,7 +444,7 @@
/*
* call-seq:
- * OCI8::Math.log10(numeric) => ocinumber
+ * OCI8::Math.log10(numeric) -> oranumber
*
* Returns the base 10 logarithm of <i>numeric</i>.
*/
@@ -464,7 +464,7 @@
/*
* call-seq:
- * OCI8::Math.sqrt(numeric) => ocinumber
+ * OCI8::Math.sqrt(numeric) -> oranumber
*
* Returns the non-negative square root of <i>numeric</i>.
*/
@@ -524,9 +524,9 @@
/*
* call-seq:
- * -ocinumber => ocinumber
+ * -onum -> oranumber
*
- * Returns an <code>OCINumber</code>, negated.
+ * Returns an <code>OraNumber</code>, negated.
*/
static VALUE onum_neg(VALUE self)
{
@@ -538,10 +538,10 @@
/*
* call-seq:
- * onum + other => onum
+ * onum + other -> oranumber
*
- * Returns a new <code>OCINumber</code> which is the sum of <code>onum</code>
- * and <code>other</code>.
+ * Returns a new <code>OraNumber</code> which is the sum of <i>onum</i>
+ * and <i>other</i>.
*/
static VALUE onum_add(VALUE lhs, VALUE rhs)
{
@@ -558,10 +558,10 @@
/*
* call-seq:
- * onum - other => onum
+ * onum - other -> oranumber
*
- * Returns a new <code>OCINumber</code> which is the difference of <code>onum</code>
- * and <code>other</code>.
+ * Returns a new <code>OraNumber</code> which is the difference of <i>onum</i>
+ * and <i>other</i>.
*/
static VALUE onum_sub(VALUE lhs, VALUE rhs)
{
@@ -578,10 +578,10 @@
/*
* call-seq:
- * onum * other => onum
+ * onum * other -> oranumber
*
- * Returns a new <code>OCINumber</code> which is the product of <code>onum</code>
- * and <code>other</code>.
+ * Returns a new <code>OraNumber</code> which is the product of <i>onum</i>
+ * and <i>other</i>.
*/
static VALUE onum_mul(VALUE lhs, VALUE rhs)
{
@@ -598,10 +598,10 @@
/*
* call-seq:
- * onum / other => onum
+ * onum / other -> oranumber
*
- * Returns a new <code>OCINumber</code> which is the result of dividing
- * <code>onum</code> by <code>other</code>.
+ * Returns a new <code>OraNumber</code> which is the result of dividing
+ * <i>onum</i> by <i>other</i>.
*/
static VALUE onum_div(VALUE lhs, VALUE rhs)
{
@@ -623,9 +623,9 @@
/*
* call-seq:
- * onum % other => onum
+ * onum % other -> oranumber
*
- * Returns the modulo after division of <code>onum</code> by <code>other</code>.
+ * Returns the modulo after division of <i>onum</i> by <i>other</i>.
*/
static VALUE onum_mod(VALUE lhs, VALUE rhs)
{
@@ -647,9 +647,9 @@
/*
* call-seq:
- * onum ** other => onum
+ * onum ** other -> oranumber
*
- * Raises <code>onum</code> the <code>other</code> power.
+ * Raises <i>onum</i> the <i>other</i> power.
*/
static VALUE onum_power(VALUE lhs, VALUE rhs)
{
@@ -677,7 +677,7 @@
/*
* call-seq:
- * onum <=> other => -1, 0, +1
+ * onum <=> other -> -1, 0, +1
*
* Returns -1, 0, or +1 depending on whether <i>onum</i> is less than,
* equal to, or greater than <i>other</i>. This is the basis for the
@@ -698,7 +698,7 @@
/*
* call-seq:
- * onum.floor => integer
+ * onum.floor -> integer
*
* Returns the largest <code>Integer</code> less than or equal to <i>onum</i>.
*/
@@ -712,7 +712,7 @@
/*
* call-seq:
- * onum.ceil => integer
+ * onum.ceil -> integer
*
* Returns the smallest <code>Integer</code> greater than or equal to
* <i>onum</i>.
@@ -727,8 +727,8 @@
/*
* call-seq:
- * onum.round => integer
- * onum.round(decplace) => onum
+ * onum.round -> integer
+ * onum.round(decplace) -> oranumber
*
* Rounds <i>onum</i> to the nearest <code>Integer</code> when no argument.
* Rounds <i>onum</i> to a specified decimal place <i>decplace</i> when one argument.
@@ -749,8 +749,8 @@
/*
* call-seq:
- * onum.truncate => integer
- * onum.truncate(decplace) => ocinumber
+ * onum.truncate -> integer
+ * onum.truncate(decplace) -> oranumber
*
* Truncates <i>onum</i> to the <code>Integer</code> when no argument.
* Truncates <i>onum</i> to a specified decimal place <i>decplace</i> when one argument.
@@ -767,13 +767,13 @@
/*
* call-seq:
- * onum.round_prec(digits) => ocinumber
+ * onum.round_prec(digits) -> oranumber
*
* Rounds <i>onum</i> to a specified number of decimal digits.
*
- * OCINumber.new(1.234).round_prec(2) #=> 1.2
- * OCINumber.new(12.34).round_prec(2) #=> 12
- * OCINumber.new(123.4).round_prec(2) #=> 120
+ * OraNumber.new(1.234).round_prec(2) #=> 1.2
+ * OraNumber.new(12.34).round_prec(2) #=> 12
+ * OraNumber.new(123.4).round_prec(2) #=> 120
*/
static VALUE onum_round_prec(VALUE self, VALUE ndigs)
{
@@ -785,7 +785,7 @@
/*
* call-seq:
- * onum.to_char(fmt = nil, nls_params = nil) => string
+ * onum.to_char(fmt = nil, nls_params = nil) -> string
*
* Returns a string containing a representation of self.
* <i>fmt</i> and <i>nls_params</i> are same meanings with
@@ -855,7 +855,7 @@
/*
* call-seq:
- * onum.to_s => string
+ * onum.to_s -> string
*
* Returns a string containing a representation of self.
*/
@@ -866,7 +866,7 @@
/*
* call-seq:
- * onum.to_i => integer
+ * onum.to_i -> integer
*
* Returns <i>onm</i> truncated to an <code>Integer</code>.
*/
@@ -895,7 +895,7 @@
/*
* call-seq:
- * onum.to_onum -> onum
+ * onum.to_onum -> oranumber
*
*/
static VALUE onum_to_onum(VALUE self)
@@ -905,7 +905,7 @@
/*
* call-seq:
- * onum.zero? => true or false
+ * onum.zero? -> true or false
*
* Returns <code>true</code> if <i>onum</i> is zero.
*
@@ -920,7 +920,7 @@
/*
* call-seq:
- * onum.abs -> ocinumber
+ * onum.abs -> oranumber
*
* Returns the absolute value of <i>onum</i>.
*
@@ -935,7 +935,7 @@
/*
* call-seq:
- * onum.shift(fixnum) => ocinumber
+ * onum.shift(fixnum) -> oranumber
*
* Returns <i>onum</i> * 10**<i>fixnum</i>
*/
@@ -978,9 +978,9 @@
/*
* call-seq:
- * onum._dump => string
+ * onum._dump -> string
*
- * Dump <i>onum</i>_ for marshaling.
+ * Dump <i>onum</i> for marshaling.
*/
static VALUE onum_dump(int argc, VALUE *argv, VALUE self)
{
@@ -994,9 +994,9 @@
/*
* call-seq:
- * OCINumber._load(string) => ocinumber
+ * OraNumber._load(string) -> oranumber
*
- * Unmarshal a dumped <code>OCINumber</code> object.
+ * Unmarshal a dumped <code>OraNumber</code> object.
*/
static VALUE
onum_s_load(VALUE klass, VALUE str)
@@ -1103,7 +1103,7 @@
#if 0 /* for rdoc */
cOCI8 = rb_define_class("OCI8", rb_cObject);
#endif
- cOCINumber = rb_define_class("OCINumber", rb_cNumeric);
+ cOCINumber = rb_define_class("OraNumber", rb_cNumeric);
mMath = rb_define_module_under(cOCI8, "Math");
/* constants for internal use. */
@@ -1197,7 +1197,7 @@
rb_define_method(cOCINumber, "_dump", onum_dump, -1);
rb_define_singleton_method(cOCINumber, "_load", onum_s_load, 1);
- oci8_define_bind_class("OCINumber", &bind_ocinumber_class);
+ oci8_define_bind_class("OraNumber", &bind_ocinumber_class);
oci8_define_bind_class("Integer", &bind_integer_class);
}
Modified: trunk/ruby-oci8/lib/oci8/compat.rb
===================================================================
--- trunk/ruby-oci8/lib/oci8/compat.rb 2008-03-08 03:10:53 UTC (rev 252)
+++ trunk/ruby-oci8/lib/oci8/compat.rb 2008-03-19 14:02:00 UTC (rev 253)
@@ -106,23 +106,3 @@
alias getColNames get_col_names
end
end
-
-class OraNumber < OCINumber
- def yaml_initialize(type, val) # :nodoc:
- initialize(val)
- end
-
- def to_yaml(opts = {}) # :nodoc:
- YAML.quick_emit(object_id, opts) do |out|
- out.scalar(taguri, self.to_s, :plain)
- end
- end
-end
-
-class OCI8
- module BindType
- OraNumber = OCINumber
- end
-end
-
-OCI8::BindType::Mapping[OraNumber] = OCI8::BindType::OraNumber
Modified: trunk/ruby-oci8/lib/oci8/object.rb
===================================================================
--- trunk/ruby-oci8/lib/oci8/object.rb 2008-03-08 03:10:53 UTC (rev 252)
+++ trunk/ruby-oci8/lib/oci8/object.rb 2008-03-19 14:02:00 UTC (rev 253)
@@ -415,7 +415,7 @@
@@result_type_to_bindtype = {
'FLOAT' => Float,
'INTEGER' => Integer,
- 'NUMBER' => OCINumber,
+ 'NUMBER' => OraNumber,
'BINARY_FLOAT' => :binary_float,
'BINARY_DOUBLE' => :binary_double,
'TIMESTAMP' => :timestamp,
Modified: trunk/ruby-oci8/lib/oci8/oci8.rb
===================================================================
--- trunk/ruby-oci8/lib/oci8/oci8.rb 2008-03-08 03:10:53 UTC (rev 252)
+++ trunk/ruby-oci8/lib/oci8/oci8.rb 2008-03-19 14:02:00 UTC (rev 253)
@@ -170,7 +170,7 @@
klass = OCI8::BindType::Float
else
# use BigDecimal instead?
- klass = OCI8::BindType::OCINumber
+ klass = OCI8::BindType::OraNumber
end
end
klass.new(con, val, nil, max_array_size)
@@ -245,11 +245,11 @@
class Cursor
# number column declared without its scale and precision. (Oracle 9.2.0.3 or above)
- @@bind_default_number = OCI8::BindType::OCINumber
+ @@bind_default_number = OCI8::BindType::OraNumber
# number value whose scale and precision is unknown
# or
# number column declared without its scale and precision. (Oracle 9.2.0.2 or below)
- @@bind_unknown_number = OCI8::BindType::OCINumber
+ @@bind_unknown_number = OCI8::BindType::OraNumber
def self.bind_default_number
@@bind_default_number
@@ -577,21 +577,33 @@
end
end
+class OraNumber
+ def yaml_initialize(type, val) # :nodoc:
+ initialize(val)
+ end
+
+ def to_yaml(opts = {}) # :nodoc:
+ YAML.quick_emit(object_id, opts) do |out|
+ out.scalar(taguri, self.to_s, :plain)
+ end
+ end
+end
+
class Numeric
def to_onum
- OCINumber.new(self)
+ OraNumber.new(self)
end
end
class String
def to_onum(format = nil, nls_params = nil)
- OCINumber.new(self, format, nls_params)
+ OraNumber.new(self, format, nls_params)
end
end
# bind or explicitly define
OCI8::BindType::Mapping[String] = OCI8::BindType::String
-OCI8::BindType::Mapping[OCINumber] = OCI8::BindType::OCINumber
+OCI8::BindType::Mapping[OraNumber] = OCI8::BindType::OraNumber
OCI8::BindType::Mapping[Fixnum] = OCI8::BindType::Integer
OCI8::BindType::Mapping[Float] = OCI8::BindType::Float
OCI8::BindType::Mapping[Integer] = OCI8::BindType::Integer
Modified: trunk/ruby-oci8/test/test_oci8.rb
===================================================================
--- trunk/ruby-oci8/test/test_oci8.rb 2008-03-08 03:10:53 UTC (rev 252)
+++ trunk/ruby-oci8/test/test_oci8.rb 2008-03-19 14:02:00 UTC (rev 253)
@@ -316,10 +316,10 @@
assert_equal(row[2], 123456789012.34)
assert_equal(row[3], 1234567890123.45)
assert_equal(row[4], 1234.5)
- assert_instance_of(OCINumber, row[0])
+ assert_instance_of(OraNumber, row[0])
assert_instance_of(Bignum, row[1])
assert_instance_of(Float, row[2])
- assert_instance_of(OCINumber, row[3])
+ assert_instance_of(OraNumber, row[3])
assert_instance_of(Float, row[4])
end
drop_table('test_table')
More information about the ruby-oci8-commit
mailing list