carray 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +0 -1
  3. data/ca_iter_block.c +32 -30
  4. data/ca_iter_dimension.c +24 -22
  5. data/ca_iter_window.c +25 -23
  6. data/ca_obj_array.c +58 -56
  7. data/ca_obj_bitarray.c +27 -27
  8. data/ca_obj_bitfield.c +46 -45
  9. data/ca_obj_block.c +77 -72
  10. data/ca_obj_fake.c +20 -20
  11. data/ca_obj_farray.c +22 -22
  12. data/ca_obj_field.c +31 -30
  13. data/ca_obj_grid.c +63 -62
  14. data/ca_obj_mapping.c +35 -32
  15. data/ca_obj_object.c +54 -54
  16. data/ca_obj_reduce.c +13 -13
  17. data/ca_obj_refer.c +42 -39
  18. data/ca_obj_repeat.c +50 -47
  19. data/ca_obj_select.c +24 -24
  20. data/ca_obj_shift.c +61 -58
  21. data/ca_obj_transpose.c +52 -51
  22. data/ca_obj_unbound_repeat.c +28 -27
  23. data/ca_obj_window.c +77 -72
  24. data/carray.gemspec +0 -2
  25. data/carray.h +190 -163
  26. data/carray_access.c +137 -136
  27. data/carray_attribute.c +24 -13
  28. data/carray_call_cfunc.c +21 -21
  29. data/carray_cast.c +106 -110
  30. data/carray_cast_func.rb +17 -17
  31. data/carray_class.c +3 -3
  32. data/carray_conversion.c +15 -15
  33. data/carray_copy.c +27 -27
  34. data/carray_core.c +22 -21
  35. data/carray_element.c +55 -47
  36. data/carray_generate.c +32 -32
  37. data/carray_iterator.c +36 -35
  38. data/carray_loop.c +37 -37
  39. data/carray_mask.c +21 -21
  40. data/carray_math.rb +18 -18
  41. data/carray_numeric.c +1 -1
  42. data/carray_operator.c +19 -18
  43. data/carray_order.c +30 -30
  44. data/carray_random.c +34 -32
  45. data/carray_sort_addr.c +12 -12
  46. data/carray_stat.c +127 -127
  47. data/carray_stat_proc.rb +152 -141
  48. data/carray_test.c +16 -16
  49. data/carray_utils.c +58 -56
  50. data/ext/calculus/carray_calculus.c +19 -20
  51. data/ext/calculus/carray_interp.c +12 -11
  52. data/ext/fortio/lib/fortio/fortran_sequential.rb +2 -2
  53. data/ext/fortio/ruby_fortio.c +1 -1
  54. data/ext/imagemap/carray_imagemap.c +14 -14
  55. data/ext/narray/ca_wrap_narray.c +30 -21
  56. data/extconf.rb +5 -0
  57. data/lib/carray/base/basic.rb +4 -3
  58. data/lib/carray/base/serialize.rb +3 -3
  59. data/lib/carray/graphics/gnuplot.rb +10 -7
  60. data/lib/carray/io/csv.rb +14 -9
  61. data/lib/carray/io/imagemagick.rb +7 -0
  62. data/lib/carray/io/sqlite3.rb +6 -4
  63. data/mkmath.rb +20 -20
  64. data/ruby_carray.c +2 -0
  65. data/ruby_ccomplex.c +3 -3
  66. data/test/test_130.rb +23 -0
  67. data/test/test_ALL.rb +2 -1
  68. data/test/test_order.rb +3 -3
  69. data/test/test_stat.rb +2 -2
  70. data/version.h +4 -4
  71. metadata +4 -37
  72. data/examples/ex001.rb +0 -10
  73. data/examples/test-int.rb +0 -13
  74. data/lib/carray/autoload/autoload_io_excel.rb +0 -5
  75. data/lib/carray/io/excel.rb +0 -26
@@ -15,9 +15,9 @@
15
15
  #include <math.h>
16
16
 
17
17
  static int
18
- find_index (int n, double *y, double yy, int *major, double *frac)
18
+ find_index (ca_size_t n, double *y, double yy, ca_size_t *major, double *frac)
19
19
  {
20
- int a, b, c, x1;
20
+ ca_size_t a, b, c, x1;
21
21
  double ya, yb, yc;
22
22
  double y1, y2;
23
23
 
@@ -33,7 +33,7 @@ find_index (int n, double *y, double yy, int *major, double *frac)
33
33
 
34
34
  /* check for equally spaced scale */
35
35
 
36
- a = (int)((yy-y[0])/(y[n-1]-y[0])*(n-1));
36
+ a = (ca_size_t)((yy-y[0])/(y[n-1]-y[0])*(n-1));
37
37
 
38
38
  if ( a >= 0 && a < n-1 ) {
39
39
  if ( (y[a] - yy) * (y[a+1] - yy) <= 0 ) {
@@ -118,7 +118,7 @@ find_index (int n, double *y, double yy, int *major, double *frac)
118
118
  */
119
119
 
120
120
  static int
121
- linear_interp_loop (CArray *ca, int *major, double *frac,
121
+ linear_interp_loop (CArray *ca, ca_size_t *major, double *frac,
122
122
  int level, int32_t *idx, double wt, double *valp)
123
123
  {
124
124
  double tmp;
@@ -154,9 +154,9 @@ linear_interp_loop (CArray *ca, int *major, double *frac,
154
154
  }
155
155
 
156
156
  static double
157
- linear_interp (CArray *ca, int *major, double *frac)
157
+ linear_interp (CArray *ca, ca_size_t *major, double *frac)
158
158
  {
159
- int32_t idx[CA_RANK_MAX];
159
+ ca_size_t idx[CA_RANK_MAX];
160
160
  double value = 0;
161
161
  linear_interp_loop(ca, major, frac, 0, idx, 1, &value);
162
162
  return value;
@@ -171,12 +171,12 @@ If value[n] is NaN, the interpolation will be made for each index of the dimensi
171
171
  static int
172
172
  ca_interpolate_loop (CArray *ca, double **scale,
173
173
  CArray **value,
174
- int *major, double *frac,
174
+ ca_size_t *major, double *frac,
175
175
  int level, double **dstp)
176
176
  {
177
177
  double val, frc;
178
- int maj;
179
- int i;
178
+ ca_size_t maj;
179
+ ca_size_t i;
180
180
  if ( level == ca->rank-1 ) {
181
181
  if ( ! value[level] ) {
182
182
  for (i=0; i<ca->dim[level]; i++) {
@@ -221,7 +221,7 @@ ca_interpolate_loop (CArray *ca, double **scale,
221
221
  int
222
222
  ca_interpolate (CArray *ca, double **scale, CArray **value, double *outp)
223
223
  {
224
- int major[CA_RANK_MAX];
224
+ ca_size_t major[CA_RANK_MAX];
225
225
  double frac[CA_RANK_MAX];
226
226
  int status;
227
227
 
@@ -239,7 +239,8 @@ rb_ca_interpolate_bilinear (int argc, VALUE *argv, volatile VALUE self)
239
239
  double *scales[CA_RANK_MAX];
240
240
  CArray *values[CA_RANK_MAX];
241
241
  CArray *scales_ca[CA_RANK_MAX];
242
- int32_t out_rank, out_dim[CA_RANK_MAX];
242
+ int8_t out_rank;
243
+ ca_size_t out_dim[CA_RANK_MAX];
243
244
  int i;
244
245
 
245
246
  rb_scan_args(argc, argv, "2", &vscales, &vvalues);
@@ -114,7 +114,7 @@ class FortranSequential
114
114
  case fmt = fmts.shift
115
115
  when String
116
116
  list = []
117
- specs = fmt.scan(/(?:\d+)(?:a\[\d+\]|\w)/)
117
+ specs = fmt.scan(/(?:\d+|)(?:a\[\d+\]|\w)/)
118
118
  while not specs.empty?
119
119
  case specs.shift
120
120
  when /(\d+)?a\[(\d+)\]/
@@ -196,7 +196,7 @@ class FortranSequential
196
196
  end
197
197
  case fmt
198
198
  when String
199
- specs = fmt.scan(/(?:\d+)(?:a\[\d+\]|\w)/)
199
+ specs = fmt.scan(/(?:\d+|)(?:a\[\d+\]|\w)/)
200
200
  while not specs.empty?
201
201
  case specs.shift
202
202
  when /(\d+)?a\[(\d+)\]/
@@ -36,7 +36,7 @@ rb_ff_read_F (VALUE mod, VALUE vbuffer, VALUE vscale, VALUE vlength, VALUE vprec
36
36
  {
37
37
  double val;
38
38
  int status;
39
- status = read_F(StringValuePtr(vbuffer), RSTRING_LEN(vbuffer),
39
+ status = read_F(StringValuePtr(vbuffer), (int) RSTRING_LEN(vbuffer),
40
40
  NUM2INT(vscale), NUM2INT(vlength), NUM2INT(vprec), &val);
41
41
  if ( ! status ) {
42
42
  rb_raise(rb_eRuntimeError, "invalid string for F descriptor");
@@ -37,9 +37,9 @@ static void
37
37
  draw_linex (CArray *ca, float x0, float y0, float x1, float y1, char *ptr)
38
38
  {
39
39
  float x, y;
40
- int ix, iy;
41
- int dim0 = ca->dim[0];
42
- int dim1 = ca->dim[1];
40
+ ca_size_t ix, iy;
41
+ ca_size_t dim0 = ca->dim[0];
42
+ ca_size_t dim1 = ca->dim[1];
43
43
  float a = (y1-y0)/(x1-x0);
44
44
  for (x=x0; x<x1; x+=1) {
45
45
  y = a*(x-x0)+y0;
@@ -56,9 +56,9 @@ static void
56
56
  draw_liney (CArray *ca, float x0, float y0, float x1, float y1, char *ptr)
57
57
  {
58
58
  float x, y;
59
- int ix, iy;
60
- int dim0 = ca->dim[0];
61
- int dim1 = ca->dim[1];
59
+ ca_size_t ix, iy;
60
+ ca_size_t dim0 = ca->dim[0];
61
+ ca_size_t dim1 = ca->dim[1];
62
62
  float a = (x1-x0)/(y1-y0);
63
63
  for (y=y0; y<y1; y+=1) {
64
64
  x = a*(y-y0)+x0;
@@ -136,8 +136,8 @@ fill_rect (CArray *image, float x[4], float y[4], char *ptr)
136
136
  CArray *mask;
137
137
  float xmin, xmax, ymin, ymax;
138
138
  float gx[4], gy[4];
139
- int32_t dim[2];
140
- int32_t i, j, ixmin, iymin, ixmax, iymax;
139
+ ca_size_t dim[2];
140
+ ca_size_t i, j, ixmin, iymin, ixmax, iymax;
141
141
  char one = 1;
142
142
 
143
143
  xmin = x[0];
@@ -162,11 +162,11 @@ fill_rect (CArray *image, float x[4], float y[4], char *ptr)
162
162
  }
163
163
  }
164
164
 
165
- ixmin = (int32_t) floor(xmin);
166
- iymin = (int32_t) floor(ymin);
165
+ ixmin = (ca_size_t) floor(xmin);
166
+ iymin = (ca_size_t) floor(ymin);
167
167
 
168
- ixmax = (int32_t) ceil(xmax) + 1;
169
- iymax = (int32_t) ceil(ymax) + 1;
168
+ ixmax = (ca_size_t) ceil(xmax) + 1;
169
+ iymax = (ca_size_t) ceil(ymax) + 1;
170
170
 
171
171
  dim[0] = ixmax - ixmin + 1;
172
172
  dim[1] = iymax - iymin + 1;
@@ -240,7 +240,7 @@ rb_im_fill_rect (VALUE self,
240
240
  }
241
241
 
242
242
  void
243
- draw_hline_gradation (CArray *image, int iy,
243
+ draw_hline_gradation (CArray *image, ca_size_t iy,
244
244
  float x0, float x1, float z0, float z1);
245
245
 
246
246
  static VALUE
@@ -251,7 +251,7 @@ rb_img_draw_hline_gradation (VALUE self, VALUE viy,
251
251
 
252
252
  Data_Get_Struct(self, CArray, image);
253
253
 
254
- draw_hline_gradation(image, NUM2INT(viy),
254
+ draw_hline_gradation(image, NUM2SIZE(viy),
255
255
  NUM2DBL(vx0), NUM2DBL(vx1), NUM2DBL(vz0), NUM2DBL(vz1));
256
256
 
257
257
  return Qnil;
@@ -123,7 +123,7 @@ rb_cary_na_ref_new_i (int argc, VALUE *argv, VALUE self, VALUE klass)
123
123
  {
124
124
  CArray *orig;
125
125
  struct NARRAY *ary;
126
- int i;
126
+ int8_t i;
127
127
 
128
128
  Data_Get_Struct(self, CArray, orig);
129
129
 
@@ -147,20 +147,20 @@ rb_cary_na_ref_new_i (int argc, VALUE *argv, VALUE self, VALUE klass)
147
147
  ary->rank = orig->rank;
148
148
  ary->shape = ALLOC_N(int, ary->rank);
149
149
  for (i=0; i<ary->rank; i++) {
150
- ary->shape[i] = orig->dim[ary->rank-1-i];
150
+ ary->shape[i] = (int) orig->dim[ary->rank-1-i];
151
151
  }
152
- ary->total = orig->elements;
152
+ ary->total = (int) orig->elements;
153
153
  ary->ptr = orig->ptr;
154
154
  }
155
155
  else {
156
- int32_t elements = 1;
156
+ ca_size_t elements = 1;
157
157
  ary->rank = argc;
158
158
  ary->shape = ALLOC_N(int, ary->rank);
159
159
  for (i=0; i<ary->rank; i++) {
160
160
  ary->shape[i] = NUM2INT(argv[i]);
161
161
  elements *= ary->shape[i];
162
162
  }
163
- ary->total = elements;
163
+ ary->total = (int) elements;
164
164
  ary->ptr = orig->ptr;
165
165
  if ( elements != orig->elements ) {
166
166
  free(ary->shape);
@@ -221,7 +221,14 @@ rb_cary_to_na_bang_i (VALUE self, VALUE klass)
221
221
  obj = na_make_empty(type, klass);
222
222
  }
223
223
  else {
224
- obj = na_make_object(type, ca->rank, (int *) ca->dim, klass);
224
+ int shape[127];
225
+ int i;
226
+
227
+ for (i=0; i<ca->rank; i++) {
228
+ shape[i] = (int) ca->dim[ca->rank-i-1];
229
+ }
230
+
231
+ obj = na_make_object(type, ca->rank, shape, klass);
225
232
  GetNArray(obj, na);
226
233
 
227
234
  fary = rb_ca_farray(self);
@@ -281,13 +288,15 @@ rb_cary_to_na_i (VALUE self, VALUE klass)
281
288
  obj = na_make_empty(type, klass);
282
289
  }
283
290
  else {
284
- obj = na_make_object(type, ca->rank, (int *) ca->dim, klass);
285
- GetNArray(obj, na);
286
-
291
+ int shape[127];
292
+
287
293
  for (i=0; i<ca->rank; i++) {
288
- na->shape[i] = ca->dim[ca->rank-i-1];
294
+ shape[i] = (int) ca->dim[ca->rank-i-1];
289
295
  }
290
296
 
297
+ obj = na_make_object(type, ca->rank, shape, klass);
298
+ GetNArray(obj, na);
299
+
291
300
  ca_copy_data(ca, na->ptr);
292
301
  }
293
302
 
@@ -337,7 +346,7 @@ rb_na_ca_ref_new (int argc, VALUE *argv, VALUE self)
337
346
  {
338
347
  volatile VALUE obj;
339
348
  struct NARRAY *na;
340
- int32_t dim[CA_RANK_MAX];
349
+ ca_size_t dim[CA_RANK_MAX];
341
350
  int8_t data_type;
342
351
  int i;
343
352
 
@@ -346,7 +355,7 @@ rb_na_ca_ref_new (int argc, VALUE *argv, VALUE self)
346
355
  data_type = na_typecode_to_ca_data_type(na->type);
347
356
 
348
357
  if ( na->total == 0 ) {
349
- int32_t zero = 0;
358
+ ca_size_t zero = 0;
350
359
  obj = rb_carray_wrap_ptr(data_type, 1, &zero, 0, NULL,
351
360
  &EMPTY_ARRAY_PTR, self); /* avoid ca->ptr == NULL */
352
361
  }
@@ -387,16 +396,16 @@ rb_na_to_ca (VALUE self)
387
396
  volatile VALUE obj;
388
397
  CArray *ca;
389
398
  struct NARRAY *na;
390
- int32_t dim[CA_RANK_MAX];
391
- int32_t data_type;
392
- int32_t i;
399
+ ca_size_t dim[CA_RANK_MAX];
400
+ ca_size_t data_type;
401
+ ca_size_t i;
393
402
 
394
403
  GetNArray(self, na);
395
404
 
396
405
  data_type = na_typecode_to_ca_data_type(na->type);
397
406
 
398
407
  if ( na->total == 0 ) {
399
- int32_t zero = 0;
408
+ ca_size_t zero = 0;
400
409
  obj = rb_carray_new(data_type, 1, &zero, 0, NULL);
401
410
  }
402
411
  else {
@@ -430,16 +439,16 @@ rb_na_to_ca_bang (VALUE self)
430
439
  volatile VALUE obj, fary;
431
440
  CArray *ca;
432
441
  struct NARRAY *na;
433
- int32_t dim[CA_RANK_MAX];
434
- int32_t data_type;
435
- int32_t i;
442
+ ca_size_t dim[CA_RANK_MAX];
443
+ ca_size_t data_type;
444
+ ca_size_t i;
436
445
 
437
446
  GetNArray(self, na);
438
447
 
439
448
  data_type = na_typecode_to_ca_data_type(na->type);
440
449
 
441
450
  if ( na->total == 0 ) {
442
- int32_t zero = 0;
451
+ ca_size_t zero = 0;
443
452
  obj = rb_carray_new(data_type, 1, &zero, 0, NULL);
444
453
  }
445
454
  else {
@@ -449,7 +458,7 @@ rb_na_to_ca_bang (VALUE self)
449
458
  dim[i] = na->shape[na->rank-i-1];
450
459
  }
451
460
 
452
- obj = rb_carray_new(data_type, na->rank, na->shape, 0, NULL);
461
+ obj = rb_carray_new(data_type, na->rank, dim, 0, NULL);
453
462
  fary = rb_ca_farray(obj);
454
463
  Data_Get_Struct(fary, CArray, ca);
455
464
 
data/extconf.rb CHANGED
@@ -68,6 +68,8 @@ end
68
68
 
69
69
  $CFLAGS += " -Wall -O2"
70
70
  # $CFLAGS += " -m128bit-long-double" ### gcc only
71
+ # $CFLAGS += " -Wno-absolute-value"
72
+ # $LDFLAGS += " -L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib"
71
73
 
72
74
  # --- check data types
73
75
 
@@ -118,6 +120,9 @@ else
118
120
  have_type("long long", header)
119
121
  have_type("float", header)
120
122
  have_type("double", header)
123
+ if have_type("long double", header)
124
+ check_sizeof("long double")
125
+ end
121
126
  if have_header("complex.h")
122
127
  complex_h = "complex.h"
123
128
  have_type("float complex", complex_h)
@@ -20,7 +20,7 @@ end
20
20
 
21
21
  class Array # :nodoc:
22
22
  def +@
23
- return CA_INT32(self)
23
+ return CA_SIZE(self)
24
24
  end
25
25
  def to_ca
26
26
  return CA_OBJECT(self)
@@ -29,7 +29,7 @@ end
29
29
 
30
30
  class Range # :nodoc:
31
31
  def +@
32
- return CA_INT32(self)
32
+ return CA_SIZE(self)
33
33
  end
34
34
  def to_ca
35
35
  return CA_OBJECT(self)
@@ -149,6 +149,7 @@ end
149
149
  "CA_DOUBLE",
150
150
  "CA_COMPLEX",
151
151
  "CA_DCOMPLEX",
152
+ "CA_SIZE",
152
153
  ].each do |name|
153
154
  eval %{
154
155
  def #{name} (*val)
@@ -920,7 +921,7 @@ class CArray
920
921
  def self.join (*argv)
921
922
  # get options
922
923
  case argv.first
923
- when Fixnum, Symbol, String
924
+ when Integer, Symbol, String
924
925
  type, = *CArray.guess_type_and_bytes(argv.shift, 0)
925
926
  else
926
927
  type = argv.flatten.first.data_type
@@ -53,11 +53,11 @@ class CArray::Serializer # :nodoc:
53
53
  char_p :data_type_name, :bytes=>8
54
54
  char_p :endian, :bytes=>4
55
55
  int32 :data_type
56
- int32 :bytes
56
+ int64 :bytes
57
57
  int32 :rank
58
- int32 :elements
58
+ int64 :elements
59
59
  int32 :has_mask
60
- array :dim, :type => CArray.int32(CA_RANK_MAX)
60
+ array :dim, :type => CArray.int64(CA_RANK_MAX)
61
61
  int32 :has_attr
62
62
  }
63
63
 
@@ -511,13 +511,13 @@ class CA::Gnuplot # :nodoc:
511
511
  list = list.clone
512
512
  conf = []
513
513
  while not list.empty? and
514
- ( list.last.is_a?(Fixnum) or
514
+ ( list.last.is_a?(Integer) or
515
515
  list.last.is_a?(Symbol) or
516
516
  list.last.is_a?(String) or
517
517
  list.last.nil? )
518
518
  conf.unshift(list.pop)
519
519
  end
520
- if conf.last.is_a?(Fixnum)
520
+ if conf.last.is_a?(Integer)
521
521
  idx = conf.pop
522
522
  case idx
523
523
  when 1,2
@@ -1920,17 +1920,21 @@ __EOD__
1920
1920
  end
1921
1921
 
1922
1922
  lines = text.split("\n").map{|line| line.strip }
1923
-
1924
- model = "RGB"
1923
+
1924
+ model = "HSV"
1925
1925
  entries = []
1926
1926
  lines.each do |line|
1927
1927
  case line
1928
- when /\A\#\s*COLOR_MODEL\s*=\s*\+(.+)\s*\Z/
1928
+ when /\A\#\s*COLOR_MODEL\s*=\s*(.+)\s*\Z/
1929
1929
  model = $1.upcase
1930
1930
  when /\A\Z/, /\A#/, /\A([FBN])\s*(.*)\Z/
1931
1931
  next
1932
1932
  else
1933
- entries.push(line.split(/\s+/)[0,8].map{|x| x.to_f})
1933
+ list = line.split(/\s+/)
1934
+ list[1] = list[1].split(/\-/)
1935
+ list[3] = list[3].split(/\-/)
1936
+ list = list.flatten.map{|x| x.to_f}
1937
+ entries.push(list)
1934
1938
  end
1935
1939
  end
1936
1940
 
@@ -1946,7 +1950,6 @@ __EOD__
1946
1950
  color[level, nil] = entry[5, 3]
1947
1951
  level += 1
1948
1952
  end
1949
-
1950
1953
  if model =~ /HSV/
1951
1954
  color[nil, 0] /= 360
1952
1955
  else
data/lib/carray/io/csv.rb CHANGED
@@ -381,14 +381,15 @@ module CA
381
381
 
382
382
  class CSVWriter # :nodoc:
383
383
 
384
- def initialize (sep=",", rs=$/, &block)
384
+ def initialize (sep=",", rs=$/, fill="", &block)
385
385
  @block = block
386
386
  @sep = sep
387
387
  @rs = rs
388
+ @fill = fill
388
389
  end
389
390
 
390
391
  def write_io (table, io)
391
- return Processor.new(table, io, @sep, @rs, &@block).run
392
+ return Processor.new(table, io, @sep, @rs, @fill, &@block).run
392
393
  end
393
394
 
394
395
  def write_string (table, string)
@@ -404,10 +405,11 @@ module CA
404
405
 
405
406
  class Processor # :nodoc:
406
407
 
407
- def initialize (table, io, sep, rs, &block)
408
+ def initialize (table, io, sep, rs, fill, &block)
408
409
  @io = io
409
410
  @sep = sep
410
411
  @rs = rs
412
+ @fill = fill
411
413
  @block = block || proc { body }
412
414
  if table.has_data_class?
413
415
  @names = table.members
@@ -426,6 +428,9 @@ module CA
426
428
  @table = table.object ### convert to CA_OBJECT
427
429
  end
428
430
  end
431
+ if @table.has_mask?
432
+ @table.unmask(@fill)
433
+ end
429
434
  @regexp_simple = /#{@sep}/o
430
435
  end
431
436
 
@@ -532,15 +537,15 @@ class CArray
532
537
  end
533
538
  end
534
539
 
535
- def save_csv (file, option = {}, rs: $/, sep: ",", mode: "w", &block)
536
- option = {:sep=>sep, :rs=>rs, :mode=>mode}.update(option)
537
- writer = CA::CSVWriter.new(option[:sep], option[:rs], &block)
540
+ def save_csv (file, option = {}, rs: $/, sep: ",", fill: "", mode: "w", &block)
541
+ option = {:sep=>sep, :rs=>rs, :fill=>fill, :mode=>mode}.update(option)
542
+ writer = CA::CSVWriter.new(option[:sep], option[:rs], option[:fill], &block)
538
543
  return writer.write_file(self, file, option[:mode])
539
544
  end
540
545
 
541
- def to_csv (io="", option ={}, rs: $/, sep: ",", &block)
542
- option = {:sep=>sep, :rs=>rs}.update(option)
543
- writer = CA::CSVWriter.new(option[:sep], option[:rs], &block)
546
+ def to_csv (io="", option ={}, rs: $/, sep: ",", fill: "", &block)
547
+ option = {:sep=>sep, :rs=>rs, :fill=>fill}.update(option)
548
+ writer = CA::CSVWriter.new(option[:sep], option[:rs], option[:fill], &block)
544
549
  case io
545
550
  when IO, StringIO
546
551
  return writer.write_io(self, io)