carray 1.3.3 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -7
- data/Rakefile +31 -0
- data/carray.gemspec +9 -14
- data/carray.h +4 -0
- data/carray_access.c +50 -8
- data/carray_conversion.c +3 -3
- data/carray_generate.c +67 -1
- data/carray_math.rb +22 -22
- data/carray_operator.c +23 -0
- data/devel/im2col.rb +17 -0
- data/ext/calculus/carray_calculus.c +235 -95
- data/ext/calculus/carray_interp.c +3 -1
- data/ext/calculus/lib/math/calculus.rb +4 -4
- data/lib/carray.rb +32 -1
- data/lib/carray/autoload/autoload_base.rb +0 -4
- data/lib/carray/autoload/autoload_gem_cairo.rb +9 -0
- data/lib/carray/autoload/autoload_gem_ffi.rb +9 -0
- data/lib/carray/autoload/autoload_gem_gnuplot.rb +2 -0
- data/lib/carray/autoload/autoload_gem_io_csv.rb +14 -0
- data/lib/carray/autoload/autoload_gem_io_pg.rb +6 -0
- data/lib/carray/autoload/autoload_gem_io_sqlite3.rb +12 -0
- data/lib/carray/autoload/autoload_gem_narray.rb +10 -0
- data/lib/carray/autoload/autoload_gem_numo_narray.rb +14 -0
- data/lib/carray/autoload/autoload_gem_opencv.rb +16 -0
- data/lib/carray/autoload/autoload_gem_rmagick.rb +23 -0
- data/lib/carray/autoload/{autoload_graphics_zimg.rb → autoload_gem_zimg.rb} +0 -0
- data/lib/carray/base/autoload.rb +47 -5
- data/lib/carray/base/basic.rb +70 -6
- data/lib/carray/base/math.rb +1 -1
- data/lib/carray/base/string.rb +242 -0
- data/lib/carray/base/struct.rb +4 -4
- data/lib/carray/io/table.rb +1 -0
- data/mkmath.rb +12 -2
- data/version.h +5 -5
- metadata +48 -141
- data/Gemfile +0 -8
- data/Gemfile.lock +0 -33
- data/ext/calculus/lib/autoload/autoload_math_calculus.rb +0 -2
- data/ext/fortio/extconf.rb +0 -3
- data/ext/fortio/lib/carray/autoload/autoload_fortran_format.rb +0 -5
- data/ext/fortio/lib/carray/io/fortran_format.rb +0 -43
- data/ext/fortio/lib/fortio.rb +0 -3
- data/ext/fortio/lib/fortio/fortran_format.rb +0 -605
- data/ext/fortio/lib/fortio/fortran_format.tab.rb +0 -536
- data/ext/fortio/lib/fortio/fortran_format.y +0 -215
- data/ext/fortio/lib/fortio/fortran_namelist.rb +0 -151
- data/ext/fortio/lib/fortio/fortran_namelist.tab.rb +0 -470
- data/ext/fortio/lib/fortio/fortran_namelist.y +0 -213
- data/ext/fortio/lib/fortio/fortran_sequential.rb +0 -345
- data/ext/fortio/ruby_fortio.c +0 -182
- data/ext/fortio/test/test_H.rb +0 -5
- data/ext/fortio/test/test_T.rb +0 -7
- data/ext/fortio/test/test_fortran_format.rb +0 -86
- data/ext/fortio/test/test_namelist.rb +0 -25
- data/ext/fortio/test/test_namelist_write.rb +0 -10
- data/ext/fortio/test/test_sequential.rb +0 -13
- data/ext/fortio/test/test_sequential2.rb +0 -13
- data/ext/fortio/work/test.rb +0 -10
- data/ext/fortio/work/test_e.rb +0 -19
- data/ext/fortio/work/test_ep.rb +0 -10
- data/ext/fortio/work/test_parse.rb +0 -12
- data/ext/imagemap/carray_imagemap.c +0 -495
- data/ext/imagemap/doc/call_graph.dot +0 -28
- data/ext/imagemap/draw.c +0 -567
- data/ext/imagemap/extconf.rb +0 -13
- data/ext/imagemap/lib/autoload/autoload_graphics_imagemap.rb +0 -1
- data/ext/imagemap/lib/graphics/imagemap.rb +0 -273
- data/ext/imagemap/lib/image_map.rb +0 -4
- data/ext/imagemap/test/swath_index.rb +0 -83
- data/ext/imagemap/test/swath_warp.rb +0 -99
- data/ext/imagemap/test/test.rb +0 -23
- data/ext/imagemap/test/test_image.rb +0 -42
- data/ext/imagemap/test/test_line.rb +0 -14
- data/ext/imagemap/test/test_rotate.rb +0 -17
- data/ext/imagemap/test/test_triangle.rb +0 -20
- data/ext/imagemap/test/test_warp.rb +0 -26
- data/ext/mathfunc/lib/autoload/autoload_math_mathfunc.rb +0 -1
- data/ext/mathfunc/lib/math/mathfunc.rb +0 -15
- data/ext/narray/README +0 -22
- data/ext/narray/ca_wrap_narray.c +0 -500
- data/ext/narray/carray_narray.c +0 -21
- data/ext/narray/extconf.rb +0 -57
- data/ext/narray/lib/autoload/autoload_math_narray.rb +0 -1
- data/ext/narray/lib/autoload/autoload_math_narray_miss.rb +0 -11
- data/ext/narray/lib/math/narray.rb +0 -17
- data/ext/narray/lib/math/narray_miss.rb +0 -45
- data/lib/carray/autoload/autoload_graphics_gnuplot.rb +0 -2
- data/lib/carray/autoload/autoload_io_csv.rb +0 -14
- data/lib/carray/autoload/autoload_io_pg.rb +0 -6
- data/lib/carray/autoload/autoload_io_sqlite3.rb +0 -12
- data/lib/carray/graphics/gnuplot.rb +0 -2131
- data/lib/carray/graphics/zimg.rb +0 -296
- data/lib/carray/io/csv.rb +0 -572
- data/lib/carray/io/pg.rb +0 -101
- data/lib/carray/io/sqlite3.rb +0 -215
- data/mkmf.log +0 -18
@@ -25,7 +25,7 @@ class CArray
|
|
25
25
|
return self
|
26
26
|
end
|
27
27
|
|
28
|
-
def solve (sc, val, eps
|
28
|
+
def solve (sc, val, type: "cubic", eps: 100 * Float::EPSILON)
|
29
29
|
func = self - val
|
30
30
|
list, output = [], []
|
31
31
|
(0...dim0-1).each do |i|
|
@@ -43,13 +43,13 @@ class CArray
|
|
43
43
|
sx[0], sx[3] = sc[i], sc[i+1]
|
44
44
|
sy[0], sy[3] = func[i], func[i+1]
|
45
45
|
sx[1], sx[2] = (2.0*sx[0]+sx[3])/3.0, (sx[0]+2.0*sx[3])/3.0
|
46
|
-
sy[1], sy[2] = func.interpolate(sc, sx[1], :type
|
47
|
-
output.push(sx.interpolate(sy, 0))
|
46
|
+
sy[1], sy[2] = func.interpolate(sc, sx[1], type: type), func.interpolate(sc, sx[2], type: type)
|
47
|
+
output.push(sx.interpolate(sy, 0, type: type))
|
48
48
|
end
|
49
49
|
return output.uniq
|
50
50
|
end
|
51
51
|
|
52
|
-
def solve2 (sc, eps
|
52
|
+
def solve2 (sc, eps: 100 * Float::EPSILON)
|
53
53
|
retvals = []
|
54
54
|
self.dim1.times do |j|
|
55
55
|
func = self[nil,j].to_ca
|
data/lib/carray.rb
CHANGED
@@ -24,5 +24,36 @@ require 'carray/base/math'
|
|
24
24
|
require 'carray/base/iterator'
|
25
25
|
require 'carray/base/struct'
|
26
26
|
require 'carray/base/inspect'
|
27
|
-
require 'carray/base/autoload'
|
28
27
|
require 'carray/base/obsolete'
|
28
|
+
require 'carray/base/string'
|
29
|
+
|
30
|
+
require "carray/carray_mathfunc"
|
31
|
+
require "carray/carray_calculus"
|
32
|
+
require "carray/math/calculus"
|
33
|
+
|
34
|
+
require 'carray/base/autoload'
|
35
|
+
require 'carray/autoload/autoload_base'
|
36
|
+
require 'carray/autoload/autoload_io_imagemagick'
|
37
|
+
require 'carray/autoload/autoload_io_table'
|
38
|
+
require 'carray/autoload/autoload_math_histogram'
|
39
|
+
require 'carray/autoload/autoload_math_interp'
|
40
|
+
require 'carray/autoload/autoload_math_recurrence'
|
41
|
+
require 'carray/autoload/autoload_object_iterator'
|
42
|
+
require 'carray/autoload/autoload_object_link'
|
43
|
+
require 'carray/autoload/autoload_object_pack'
|
44
|
+
|
45
|
+
require 'carray/autoload/autoload_gem_gnuplot'
|
46
|
+
require 'carray/autoload/autoload_gem_narray'
|
47
|
+
require 'carray/autoload/autoload_gem_numo_narray'
|
48
|
+
require 'carray/autoload/autoload_gem_io_csv'
|
49
|
+
require 'carray/autoload/autoload_gem_io_sqlite3'
|
50
|
+
require 'carray/autoload/autoload_gem_rmagick'
|
51
|
+
require 'carray/autoload/autoload_gem_cairo'
|
52
|
+
require 'carray/autoload/autoload_gem_opencv'
|
53
|
+
require 'carray/autoload/autoload_gem_ffi'
|
54
|
+
|
55
|
+
#require 'carray/autoload/autoload_gem_io_pg'
|
56
|
+
#require 'carray/autoload/autoload_gem_zimg'
|
57
|
+
|
58
|
+
undef autoload_method
|
59
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
autoload_method "CArray.load_csv", "carray-io-csv"
|
2
|
+
autoload_method "CArray.from_csv", "carray-io-csv"
|
3
|
+
|
4
|
+
class CArray
|
5
|
+
autoload_method "save_csv", "carray-io-csv"
|
6
|
+
autoload_method "to_csv", "carray-io-csv"
|
7
|
+
autoload_method "to_tabular", "carray-io-csv"
|
8
|
+
end
|
9
|
+
|
10
|
+
module CA
|
11
|
+
autoload :CSVReader, "carray-io-csv"
|
12
|
+
autoload :CSVWriter, "carray-io-csv"
|
13
|
+
end
|
14
|
+
|
@@ -0,0 +1,12 @@
|
|
1
|
+
autoload_method "CArray.load_sqlite3", "carray-io-sqlite3"
|
2
|
+
|
3
|
+
class CArray
|
4
|
+
autoload_method "unblob", "carray-io-sqlite3"
|
5
|
+
autoload_method "to_sqlite3", "carray-io-sqlite3"
|
6
|
+
end
|
7
|
+
|
8
|
+
if Object.const_defined?(:SQLite3)
|
9
|
+
require "carray-io-sqlite3"
|
10
|
+
else
|
11
|
+
autoload :SQLite3, "carray-io-sqlite3"
|
12
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#autoload :Numo, "carray-numo-narray"
|
2
|
+
|
3
|
+
class CArray
|
4
|
+
autoload_method :to_numo, "carray-numo-narray"
|
5
|
+
autoload_method :numo, "carray-numo-narray"
|
6
|
+
end
|
7
|
+
|
8
|
+
module Numo
|
9
|
+
class NArray
|
10
|
+
autoload_method :to_ca, "carray-numo-narray"
|
11
|
+
autoload_method :ca, "carray-numo-narray"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module OpenCV
|
2
|
+
class CvMat
|
3
|
+
autoload_method "ca", "carray-opencv"
|
4
|
+
autoload_method "to_ca", "carray-opencv"
|
5
|
+
autoload_method "from_ca", "carray-opencv"
|
6
|
+
autoload_method "image", "carray-opencv"
|
7
|
+
end
|
8
|
+
class IplImage < CvMat
|
9
|
+
autoload_method "ca", "carray-opencv"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class CArray
|
14
|
+
autoload_method "to_cvmat", "carray-opencv"
|
15
|
+
autoload_method "to_iplimage", "carray-opencv"
|
16
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Magick
|
2
|
+
class Image
|
3
|
+
autoload_method "export_pixels_to_ca", "carray-rmagick"
|
4
|
+
autoload_method "import_pixels_from_ca", "carray-rmagick"
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
class CArray
|
9
|
+
autoload_method "self.load_image", "carray-rmagick"
|
10
|
+
autoload_method "save_image", "carray-rmagick"
|
11
|
+
autoload_method "display_image", "carray-rmagick"
|
12
|
+
autoload_method "to_image", "carray-rmagick"
|
13
|
+
end
|
14
|
+
|
15
|
+
autoload :CAMagickImage, "carray-rmagick"
|
16
|
+
|
17
|
+
module Magick
|
18
|
+
class Image
|
19
|
+
autoload_method "ca", "carray-rmagick"
|
20
|
+
autoload_method "to_ca", "carray-rmagick"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
File without changes
|
data/lib/carray/base/autoload.rb
CHANGED
@@ -13,7 +13,11 @@
|
|
13
13
|
def autoload_method (method, library)
|
14
14
|
eval %{
|
15
15
|
def #{method} (*argv, &block)
|
16
|
-
|
16
|
+
begin
|
17
|
+
require "#{library}"
|
18
|
+
rescue LoadError
|
19
|
+
raise "error in autoloading '#{library}' hooked by method '#{method}', check gem installation."
|
20
|
+
end
|
17
21
|
#{method}(*argv, &block)
|
18
22
|
end
|
19
23
|
}
|
@@ -23,7 +27,11 @@ class Class
|
|
23
27
|
def autoload_method (method, library)
|
24
28
|
class_eval %{
|
25
29
|
def #{method} (*argv, &block)
|
26
|
-
|
30
|
+
begin
|
31
|
+
require "#{library}"
|
32
|
+
rescue LoadError
|
33
|
+
raise "error in autoloading '#{library}' hooked by method '#{method}', check gem installation."
|
34
|
+
end
|
27
35
|
#{method}(*argv, &block)
|
28
36
|
end
|
29
37
|
}
|
@@ -34,7 +42,11 @@ class Module
|
|
34
42
|
def autoload_method (method, library)
|
35
43
|
class_eval %{
|
36
44
|
def #{method} (*argv, &block)
|
37
|
-
|
45
|
+
begin
|
46
|
+
require "#{library}"
|
47
|
+
rescue LoadError
|
48
|
+
raise "error in autoloading '#{library}' hooked by method '#{method}', check gem installation."
|
49
|
+
end
|
38
50
|
#{method}(*argv, &block)
|
39
51
|
end
|
40
52
|
}
|
@@ -46,7 +58,11 @@ class Module
|
|
46
58
|
class_eval %{
|
47
59
|
module_function
|
48
60
|
def #{method} (*argv, &block)
|
49
|
-
|
61
|
+
begin
|
62
|
+
require "#{library}"
|
63
|
+
rescue LoadError
|
64
|
+
raise "error in autoloading '#{library}' hooked by method '#{method}', check gem installation."
|
65
|
+
end
|
50
66
|
#{method}(*argv, &block)
|
51
67
|
end
|
52
68
|
}
|
@@ -87,6 +103,33 @@ module CA
|
|
87
103
|
|
88
104
|
end
|
89
105
|
|
106
|
+
__END__
|
107
|
+
names = {"carray" => true}
|
108
|
+
Gem.path.each do |path|
|
109
|
+
gems = File.join(path, "gems")
|
110
|
+
if File.directory?(gems)
|
111
|
+
Dir.chdir(gems) {
|
112
|
+
Dir["carray-*"].sort.reverse.each do |dir|
|
113
|
+
name = dir.sub(/\-\d+\.\d+\.\d+\z/, '')
|
114
|
+
next if names[name]
|
115
|
+
lib = File.join(dir, "lib")
|
116
|
+
if File.directory?(lib)
|
117
|
+
Dir.chdir(lib) {
|
118
|
+
Dir["carray/autoload/autoload_*"].each do |loader|
|
119
|
+
begin
|
120
|
+
load File.expand_path(File.join(gems, dir, lib, loader.sub(/\.rb\z/, "")))
|
121
|
+
rescue LoadError
|
122
|
+
end
|
123
|
+
end
|
124
|
+
}
|
125
|
+
end
|
126
|
+
names[name] = true
|
127
|
+
end
|
128
|
+
}
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
__END__
|
90
133
|
CA.each_load_path("carray/autoload") {
|
91
134
|
Dir["autoload_*.rb"].each do |basename|
|
92
135
|
if basename =~ /\A(autoload_.+)\.rb\Z/
|
@@ -98,4 +141,3 @@ CA.each_load_path("carray/autoload") {
|
|
98
141
|
end
|
99
142
|
}
|
100
143
|
|
101
|
-
undef autoload_method
|
data/lib/carray/base/basic.rb
CHANGED
@@ -374,15 +374,23 @@ class CArray
|
|
374
374
|
# Reutrns the reference which rank is reduced
|
375
375
|
# by eliminating the dimensions which size == 1
|
376
376
|
def compacted
|
377
|
-
|
378
|
-
|
377
|
+
if rank == 1
|
378
|
+
return self[]
|
379
|
+
else
|
380
|
+
newdim = dim.reject{|x| x == 1 }
|
381
|
+
return ( rank != newdim.size ) ? reshape(*newdim) : self[]
|
382
|
+
end
|
379
383
|
end
|
380
384
|
|
381
385
|
# Returns the array which rank is reduced
|
382
386
|
# by eliminating the dimensions which size == 1
|
383
387
|
def compact
|
384
|
-
|
385
|
-
|
388
|
+
if rank == 1
|
389
|
+
return self.to_ca
|
390
|
+
else
|
391
|
+
newdim = dim.reject{|x| x == 1 }
|
392
|
+
return ( rank != newdim.size ) ? reshape(*newdim).to_ca : self.to_ca
|
393
|
+
end
|
386
394
|
end
|
387
395
|
|
388
396
|
# Returns the reference which elements are sorted by the comparison method
|
@@ -421,6 +429,50 @@ class CArray
|
|
421
429
|
end
|
422
430
|
end
|
423
431
|
|
432
|
+
def nlargest (n)
|
433
|
+
obj = self.to_ca
|
434
|
+
list = []
|
435
|
+
n.times do |i|
|
436
|
+
k = obj.max_addr
|
437
|
+
list << obj[k]
|
438
|
+
obj[k] = UNDEF
|
439
|
+
end
|
440
|
+
list.to_ca.to_type(data_type)
|
441
|
+
end
|
442
|
+
|
443
|
+
def nlargest_addr (n)
|
444
|
+
obj = self.to_ca
|
445
|
+
list = []
|
446
|
+
n.times do |i|
|
447
|
+
k = obj.max_addr
|
448
|
+
list << k
|
449
|
+
obj[k] = UNDEF
|
450
|
+
end
|
451
|
+
CA_INT64(list)
|
452
|
+
end
|
453
|
+
|
454
|
+
def nsmallest (n)
|
455
|
+
obj = self.to_ca
|
456
|
+
list = []
|
457
|
+
n.times do |i|
|
458
|
+
k = obj.min_addr
|
459
|
+
list << obj[k]
|
460
|
+
obj[k] = UNDEF
|
461
|
+
end
|
462
|
+
list.to_ca.to_type(data_type)
|
463
|
+
end
|
464
|
+
|
465
|
+
def nsmallest_addr (n)
|
466
|
+
obj = self.to_ca
|
467
|
+
list = []
|
468
|
+
n.times do |i|
|
469
|
+
k = obj.min_addr
|
470
|
+
list << k
|
471
|
+
obj[k] = UNDEF
|
472
|
+
end
|
473
|
+
CA_INT64(list)
|
474
|
+
end
|
475
|
+
|
424
476
|
# Returns (1,n) array from 1-dimensional array
|
425
477
|
def to_row
|
426
478
|
if rank != 1
|
@@ -688,7 +740,7 @@ class CArray
|
|
688
740
|
return CArray.int32(*dim).seq!
|
689
741
|
end
|
690
742
|
|
691
|
-
def index (n)
|
743
|
+
def index (n = 0)
|
692
744
|
unless n.is_a?(Integer)
|
693
745
|
raise ArgumentError, "argument should be an integer"
|
694
746
|
end
|
@@ -735,6 +787,18 @@ class CArray
|
|
735
787
|
return template(:boolean) { 1 }
|
736
788
|
end
|
737
789
|
|
790
|
+
def contains (*list)
|
791
|
+
result = self.false()
|
792
|
+
list.each do |item|
|
793
|
+
result = result | self.eq(item)
|
794
|
+
end
|
795
|
+
return result
|
796
|
+
end
|
797
|
+
|
798
|
+
def between (a, b)
|
799
|
+
return (self >= a) & (self <= b)
|
800
|
+
end
|
801
|
+
|
738
802
|
# Returns map
|
739
803
|
def map (&block)
|
740
804
|
return self.convert(CA_OBJECT, &block).to_a
|
@@ -794,8 +858,8 @@ class CArray
|
|
794
858
|
return obj
|
795
859
|
end
|
796
860
|
|
797
|
-
end
|
798
861
|
|
862
|
+
end
|
799
863
|
|
800
864
|
class CArray
|
801
865
|
|
data/lib/carray/base/math.rb
CHANGED
@@ -0,0 +1,242 @@
|
|
1
|
+
require "date"
|
2
|
+
|
3
|
+
class CArray
|
4
|
+
|
5
|
+
def test (&block)
|
6
|
+
return convert(:boolean) {|v| yield(v) ? true : false }
|
7
|
+
end
|
8
|
+
|
9
|
+
def str_len ()
|
10
|
+
return convert(:int, &:length)
|
11
|
+
end
|
12
|
+
|
13
|
+
def str_size ()
|
14
|
+
return convert(:int, &:size)
|
15
|
+
end
|
16
|
+
|
17
|
+
def str_bytesize ()
|
18
|
+
return convert(:int, &:bytesize)
|
19
|
+
end
|
20
|
+
|
21
|
+
def str_gsub (*args, &block)
|
22
|
+
return convert() {|s| s.gsub(*args, &block) }
|
23
|
+
end
|
24
|
+
|
25
|
+
def str_sub (*args, &block)
|
26
|
+
return convert() {|s| s.sub(*args, &block) }
|
27
|
+
end
|
28
|
+
|
29
|
+
def str_encode (*args)
|
30
|
+
return convert() {|s| s.encode(*args) }
|
31
|
+
end
|
32
|
+
|
33
|
+
def str_force_encoding (encoding)
|
34
|
+
return convert() {|s| s.force_encoding(encoding) }
|
35
|
+
end
|
36
|
+
|
37
|
+
def str_encoding ()
|
38
|
+
return convert(&:encoding)
|
39
|
+
end
|
40
|
+
|
41
|
+
def str_is_end_with (*args)
|
42
|
+
return test {|s| s.end_with?(*args) }
|
43
|
+
end
|
44
|
+
|
45
|
+
def str_is_start_with (*args)
|
46
|
+
return test {|s| s.start_with?(*args) }
|
47
|
+
end
|
48
|
+
|
49
|
+
def str_includes (substr)
|
50
|
+
return test {|s| s.include?(substr) }
|
51
|
+
end
|
52
|
+
|
53
|
+
alias str_contains str_includes
|
54
|
+
|
55
|
+
def str_index (*args)
|
56
|
+
return convert(:int) {|s| s.index(*args) }
|
57
|
+
end
|
58
|
+
|
59
|
+
def str_rindex (*args)
|
60
|
+
return convert(:int) {|s| s.rindex(*args) }
|
61
|
+
end
|
62
|
+
|
63
|
+
def str_intern ()
|
64
|
+
return convert(&:intern)
|
65
|
+
end
|
66
|
+
|
67
|
+
def str_scrub ()
|
68
|
+
return convert(&:scrub)
|
69
|
+
end
|
70
|
+
|
71
|
+
def str_downcase ()
|
72
|
+
return convert(&:downcase)
|
73
|
+
end
|
74
|
+
|
75
|
+
def str_upcase ()
|
76
|
+
return convert(&:upcase)
|
77
|
+
end
|
78
|
+
|
79
|
+
def str_capitalize ()
|
80
|
+
return convert(&:capitalize)
|
81
|
+
end
|
82
|
+
|
83
|
+
def str_swapcase ()
|
84
|
+
return convert(&:swapcase)
|
85
|
+
end
|
86
|
+
|
87
|
+
def str_chomp (*args)
|
88
|
+
return convert() {|s| s.chomp(*args) }
|
89
|
+
end
|
90
|
+
|
91
|
+
def str_chop ()
|
92
|
+
return convert(&:chop)
|
93
|
+
end
|
94
|
+
|
95
|
+
def str_chr ()
|
96
|
+
return convert(&:chr)
|
97
|
+
end
|
98
|
+
|
99
|
+
def str_clear ()
|
100
|
+
return convert(&:clear)
|
101
|
+
end
|
102
|
+
|
103
|
+
def str_count (*args)
|
104
|
+
return convert(:int) {|s| s.count(*args) }
|
105
|
+
end
|
106
|
+
|
107
|
+
def str_delete (*args)
|
108
|
+
return convert() {|s| s.delete(*args) }
|
109
|
+
end
|
110
|
+
|
111
|
+
def str_delete_prefix (prefix)
|
112
|
+
return convert() {|s| s.delete_prefix(prefix) }
|
113
|
+
end
|
114
|
+
|
115
|
+
def str_delete_suffix (suffix)
|
116
|
+
return convert() {|s| s.delete_suffix(suffix) }
|
117
|
+
end
|
118
|
+
|
119
|
+
def str_dump ()
|
120
|
+
return convert(&:dump)
|
121
|
+
end
|
122
|
+
|
123
|
+
def str_center (*args)
|
124
|
+
return convert() {|s| s.center(*args) }
|
125
|
+
end
|
126
|
+
|
127
|
+
def str_ljust (*args)
|
128
|
+
return convert() {|s| s.ljust(*args) }
|
129
|
+
end
|
130
|
+
|
131
|
+
def str_rjust (*args)
|
132
|
+
return convert() {|s| s.rjust(*args) }
|
133
|
+
end
|
134
|
+
|
135
|
+
def str_to_i ()
|
136
|
+
return convert(&:to_i)
|
137
|
+
end
|
138
|
+
|
139
|
+
def str_to_f ()
|
140
|
+
return convert(&:to_f)
|
141
|
+
end
|
142
|
+
|
143
|
+
def str_to_r ()
|
144
|
+
return convert(&:to_r)
|
145
|
+
end
|
146
|
+
|
147
|
+
def str_strip ()
|
148
|
+
return convert(&:strip)
|
149
|
+
end
|
150
|
+
|
151
|
+
def str_rstrip ()
|
152
|
+
return convert(&:rstrip)
|
153
|
+
end
|
154
|
+
|
155
|
+
def str_lstrip ()
|
156
|
+
return convert(&:lstrip)
|
157
|
+
end
|
158
|
+
|
159
|
+
def str_is_empty ()
|
160
|
+
return test(&:empty?)
|
161
|
+
end
|
162
|
+
|
163
|
+
def str_matches (*args)
|
164
|
+
if args.size == 1 && args.first.is_a?(Regexp)
|
165
|
+
regexp = args.first
|
166
|
+
return test {|v| v =~ regexp }
|
167
|
+
else
|
168
|
+
mask = template(:boolean) { false }
|
169
|
+
args.each do |str|
|
170
|
+
addr = search(str)
|
171
|
+
mask[addr] = true if addr
|
172
|
+
end
|
173
|
+
return mask
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
def str_extract (regexp, replace = '\0')
|
178
|
+
return convert {|s| regexp.match(s) {|m| m[0].sub(regexp, replace) } || "" }
|
179
|
+
end
|
180
|
+
|
181
|
+
def str_to_datetime (template = nil)
|
182
|
+
if template
|
183
|
+
return convert() {|v| DateTime.strptime(v, template) }
|
184
|
+
else
|
185
|
+
return convert() {|v| DateTime.parse(v) }
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
def str_to_time (template = nil)
|
190
|
+
if template
|
191
|
+
return str_strptime(template)
|
192
|
+
else
|
193
|
+
return convert() {|v| Time.parse(v) }
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
def time_format (template = nil)
|
198
|
+
if template
|
199
|
+
return str_strftime(template)
|
200
|
+
else
|
201
|
+
return convert(&:to_s)
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
def time_year
|
206
|
+
return convert(:int, &:year)
|
207
|
+
end
|
208
|
+
|
209
|
+
def time_month
|
210
|
+
return convert(:int, &:month)
|
211
|
+
end
|
212
|
+
|
213
|
+
def time_day
|
214
|
+
return convert(:int, &:day)
|
215
|
+
end
|
216
|
+
|
217
|
+
def time_hour
|
218
|
+
return convert(:int, &:hour)
|
219
|
+
end
|
220
|
+
|
221
|
+
def time_minute
|
222
|
+
return convert(:int, &:minute)
|
223
|
+
end
|
224
|
+
|
225
|
+
def time_second
|
226
|
+
return convert(:double) {|d| d.second + d.second_fraction }
|
227
|
+
end
|
228
|
+
|
229
|
+
def time_jd
|
230
|
+
return convert(:int, &:jd)
|
231
|
+
end
|
232
|
+
|
233
|
+
def time_ajd
|
234
|
+
return convert(:double, &:ajd)
|
235
|
+
end
|
236
|
+
|
237
|
+
def time_is_leap
|
238
|
+
return test(&:leap?)
|
239
|
+
end
|
240
|
+
|
241
|
+
end
|
242
|
+
|