kyanite 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Div +1 -7
- data/History.txt +3 -0
- data/Manifest.txt +0 -5
- data/README.txt +6 -6
- data/Rakefile.rb +27 -34
- data/lib/kyanite/array/array.rb +2 -9
- data/lib/kyanite/array/array2.rb +5 -5
- data/lib/kyanite/array/matrix2.rb +13 -13
- data/lib/kyanite/array.rb +1 -0
- data/lib/kyanite/array_of_enumerables.rb +1 -1
- data/lib/kyanite/array_of_numerics.rb +1 -1
- data/lib/kyanite/array_of_strings.rb +1 -1
- data/lib/kyanite/basics.rb +1 -2
- data/lib/kyanite/dictionary.rb +4 -4
- data/lib/kyanite/enumerable/enumerable_enumerables.rb +5 -5
- data/lib/kyanite/enumerable/enumerable_numerics.rb +4 -4
- data/lib/kyanite/enumerable/enumerable_strings.rb +6 -5
- data/lib/kyanite/enumerable/structure.rb +28 -25
- data/lib/kyanite/enumerable.rb +1 -1
- data/lib/kyanite/general/callerutils.rb +1 -1
- data/lib/kyanite/general/classutils.rb +23 -24
- data/lib/kyanite/general/kernel.rb +6 -6
- data/lib/kyanite/general/nil.rb +4 -4
- data/lib/kyanite/general/object.rb +1 -1
- data/lib/kyanite/general/true_false.rb +1 -1
- data/lib/kyanite/general/undoable.rb +7 -7
- data/lib/kyanite/general.rb +1 -1
- data/lib/kyanite/hash.rb +22 -22
- data/lib/kyanite/matrix2.rb +1 -1
- data/lib/kyanite/nil.rb +1 -1
- data/lib/kyanite/numeric/float.rb +1 -1
- data/lib/kyanite/numeric/integer.rb +7 -7
- data/lib/kyanite/numeric/numeric.rb +9 -9
- data/lib/kyanite/numeric.rb +1 -1
- data/lib/kyanite/operation/call_tracker.rb +1 -1
- data/lib/kyanite/operation/regexp.rb +1 -1
- data/lib/kyanite/operation/unit_test.rb +1 -1
- data/lib/kyanite/operation.rb +1 -1
- data/lib/kyanite/optimizer.rb +4 -4
- data/lib/kyanite/rake.rb +1 -1
- data/lib/kyanite/range.rb +4 -4
- data/lib/kyanite/set.rb +4 -6
- data/lib/kyanite/string/cast.rb +4 -4
- data/lib/kyanite/string/chars.rb +5 -5
- data/lib/kyanite/string/diff.rb +1 -1
- data/lib/kyanite/string/div.rb +1 -1
- data/lib/kyanite/string/include.rb +6 -6
- data/lib/kyanite/string/list.rb +1 -1
- data/lib/kyanite/string/nested.rb +1 -1
- data/lib/kyanite/string/split.rb +3 -3
- data/lib/kyanite/string.rb +1 -1
- data/lib/kyanite/symbol.rb +1 -1
- data/lib/kyanite/tree.rb +1 -1
- data/lib/kyanite/undoable.rb +1 -1
- data/lib/kyanite/unit_test.rb +1 -1
- data/lib/kyanite.rb +6 -6
- data/test/string/test_list.rb +2 -1
- data/test/test_hash.rb +1 -1
- data/test/test_range.rb +2 -1
- metadata +3 -8
- data/0_rake_test.bat +0 -13
- data/1_rake_install_gem.bat +0 -20
- data/3_rake_deploy.bat +0 -4
- data/4_ruby_script_console.bat +0 -13
- data/lib/kyanite/operation/rake.rb +0 -119
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# ruby encoding: utf-8
|
2
2
|
|
3
3
|
require 'facets/kernel/singleton_class' # Easy access to an object‘s "special" class, otherwise known as it‘s eigen or meta class.
|
4
4
|
require 'facets/class/descendants' # Methode descendants
|
@@ -28,20 +28,20 @@ class Class
|
|
28
28
|
return false
|
29
29
|
end
|
30
30
|
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
31
|
+
# Die Methode to_class wandelt einen Klassennamen in eine Klasse.
|
32
|
+
# Die Methode gibt es insbesondere für String und Symbol, siehe String#to_class, Symbol#to_class
|
33
|
+
# Für Class ist sie einfach transparent, d.h. sie liefert self.
|
34
|
+
# Tests and examples see TestKyaniteClassutils
|
35
35
|
#
|
36
36
|
def to_class
|
37
37
|
self
|
38
38
|
end
|
39
39
|
|
40
40
|
|
41
|
-
#
|
42
|
-
#
|
43
|
-
#
|
44
|
-
#
|
41
|
+
# Gegenstück zu to_class:
|
42
|
+
# Wandelt eine Klasse in einen Klassennamen um, der nur Kleinbuchstaben enthält.
|
43
|
+
# Siehe String#to_classname, Symbol#to_classname
|
44
|
+
# Tests and examples see TestKyaniteClassutils
|
45
45
|
#
|
46
46
|
def to_classname
|
47
47
|
self.to_s.demodulize.underscore
|
@@ -56,18 +56,18 @@ end # class
|
|
56
56
|
|
57
57
|
class Symbol
|
58
58
|
|
59
|
-
#
|
60
|
-
#
|
61
|
-
#
|
59
|
+
# Wandelt ein Symbol in einen Klassennamen, der nur Kleinbuchstaben enthält.
|
60
|
+
# Siehe String#to_classname
|
61
|
+
# Tests and examples see TestKyaniteClassutils
|
62
62
|
#
|
63
63
|
def to_classname
|
64
64
|
self.to_s.to_classname
|
65
65
|
end
|
66
66
|
|
67
|
-
#
|
68
|
-
#
|
69
|
-
#
|
70
|
-
#
|
67
|
+
# Wandelt einen Klassennamen in eine Klasse.
|
68
|
+
# Akzeptiert sowohl CamelCase als auch down_case.
|
69
|
+
# Die Methode gibt es auch für String und Class.
|
70
|
+
# Tests and examples see TestKyaniteClassutils
|
71
71
|
#
|
72
72
|
def to_class
|
73
73
|
self.to_s.to_class
|
@@ -100,10 +100,10 @@ class String
|
|
100
100
|
|
101
101
|
|
102
102
|
|
103
|
-
#
|
104
|
-
#
|
105
|
-
#
|
106
|
-
#
|
103
|
+
# Wandelt einen Klassennamen in eine Klasse.
|
104
|
+
# Akzeptiert sowohl CamelCase als auch down_case.
|
105
|
+
# Die Methode gibt es auch für Symbol und Class.
|
106
|
+
# Tests and examples see TestKyaniteClassutils
|
107
107
|
#
|
108
108
|
def to_class
|
109
109
|
self.camelize.constantize
|
@@ -115,13 +115,12 @@ class String
|
|
115
115
|
|
116
116
|
|
117
117
|
# The reverse of +camelize+. Makes an underscored, lowercase form from the expression in the string.
|
118
|
-
#
|
119
118
|
# Changes '::' to '/' to convert namespaces to paths.
|
120
119
|
#
|
121
120
|
# Examples:
|
122
121
|
# "ActiveRecord".underscore # => "active_record"
|
123
122
|
# "ActiveRecord::Errors".underscore # => active_record/errors
|
124
|
-
#
|
123
|
+
# From ActiveSupport, Copyright (c) 2005 David Heinemeier Hansson. See License.txt.
|
125
124
|
#
|
126
125
|
def underscore
|
127
126
|
self.gsub(/::/, '/').
|
@@ -143,7 +142,7 @@ class String
|
|
143
142
|
# "active_record".camelize(:lower) # => "activeRecord"
|
144
143
|
# "active_record/errors".camelize # => "ActiveRecord::Errors"
|
145
144
|
# "active_record/errors".camelize(:lower) # => "activeRecord::Errors"
|
146
|
-
#
|
145
|
+
# From ActiveSupport, Copyright (c) 2005 David Heinemeier Hansson. See License.txt.
|
147
146
|
#
|
148
147
|
def camelize(first_letter_in_uppercase = true)
|
149
148
|
if first_letter_in_uppercase
|
@@ -159,7 +158,7 @@ class String
|
|
159
158
|
# Examples:
|
160
159
|
# "ActiveRecord::CoreExtensions::String::Inflections".demodulize # => "Inflections"
|
161
160
|
# "Inflections".demodulize # => "Inflections"
|
162
|
-
#
|
161
|
+
# From ActiveSupport, Copyright (c) 2005 David Heinemeier Hansson. See License.txt.
|
163
162
|
#
|
164
163
|
def demodulize
|
165
164
|
self.gsub(/^.*::/, '')
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# ruby encoding: utf-8
|
2
2
|
require 'facets/timer'
|
3
3
|
require 'rbconfig'
|
4
4
|
|
@@ -50,9 +50,9 @@ module KKernel
|
|
50
50
|
|
51
51
|
|
52
52
|
|
53
|
-
#
|
54
|
-
#
|
55
|
-
#
|
53
|
+
# Stellt für den nachfolgenden Block die Ruby-Warnungen ab.
|
54
|
+
# Nützlich, um z.B. Konstanten zu überschreiben.
|
55
|
+
# Quelle: Rails http://api.rubyonrails.org/classes/Kernel.html#M001639
|
56
56
|
def silence_warnings
|
57
57
|
old_verbose, $VERBOSE = $VERBOSE, nil
|
58
58
|
yield
|
@@ -61,8 +61,8 @@ module KKernel
|
|
61
61
|
end
|
62
62
|
|
63
63
|
|
64
|
-
#
|
65
|
-
#
|
64
|
+
# Vereinfacht die require-Statements in den Tests.
|
65
|
+
# Wird in allen Kyanite-Tests angewendet, Verwendung siehe dort.
|
66
66
|
#
|
67
67
|
def smart_load_path(__file__ = nil)
|
68
68
|
__file__ = caller[0] unless __file__
|
data/lib/kyanite/general/nil.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# ruby encoding: utf-8
|
2
2
|
# [ | *Kyanite* | Object | Array | Set | Enumerable | Hash | ] | Kyanite | TrueClass | FalseClass | *NilClass* | Div |
|
3
3
|
#
|
4
4
|
# ---
|
@@ -9,9 +9,9 @@
|
|
9
9
|
# (meist läuft irgendwas schief wenn man es unerwartet mit nil zu tun hat)
|
10
10
|
# aber man verunstaltet seinen Quellcode schnell mit Fallunterscheidungen, die den nil-Fall behandeln.
|
11
11
|
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
12
|
+
# In Kyanite werden daher zahlreiche Methoden für nil definiert.
|
13
|
+
# Nil verhält sich damit wie alle anderen Objekte auch.
|
14
|
+
# Man kann immer noch nach Nil fragen, wenn man es möchte, aber man muss es nicht mehr tun!
|
15
15
|
#
|
16
16
|
class NilClass
|
17
17
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# ruby encoding: utf-8
|
2
2
|
|
3
3
|
# [ | Kyanite | *Object* | Array | Set | Enumerable | Hash | ] | *Object* | String | Symbol | Numeric | Class |
|
4
4
|
# [ ] | Object | KKernel | CallerUtils | *Undoable* | Class |
|
@@ -13,8 +13,8 @@ module Undoable
|
|
13
13
|
|
14
14
|
@@undoable_history = Hash.new
|
15
15
|
|
16
|
-
#
|
17
|
-
#
|
16
|
+
# Speichert ein Objekt.
|
17
|
+
# Verwendet standardmäßig Object#dup. Für komplexere Objekte muss allerdings Object#deep_copy genutzt werden.
|
18
18
|
#
|
19
19
|
def save(method=:dup)
|
20
20
|
return if self == @@undoable_history[self.object_id] # nichts zu tun
|
@@ -22,16 +22,16 @@ module Undoable
|
|
22
22
|
end
|
23
23
|
|
24
24
|
|
25
|
-
#
|
26
|
-
#
|
25
|
+
# Rückgriff auf den gespeicherten Zustand eines Objektes.
|
26
|
+
# Der gespeicherte Zustand verbleibt im Speicher.
|
27
27
|
#
|
28
28
|
def load_and_keep
|
29
29
|
@@undoable_history[self.object_id]
|
30
30
|
end
|
31
31
|
|
32
32
|
|
33
|
-
#
|
34
|
-
#
|
33
|
+
# Rückgriff auf den gespeicherten Zustand eines Objektes.
|
34
|
+
# Der gespeicherte Zustand wird verworfen.
|
35
35
|
#
|
36
36
|
def load_and_delete
|
37
37
|
@@undoable_history.delete(self.object_id)
|
data/lib/kyanite/general.rb
CHANGED
data/lib/kyanite/hash.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# ruby encoding: utf-8
|
2
2
|
require 'active_support/core_ext/hash/slice' # Slice a hash to include only the given keys.
|
3
3
|
require 'active_support/core_ext/hash/reverse_merge' # Merges the caller into +other_hash+.
|
4
4
|
require 'kyanite/enumerable' # is_collection?
|
@@ -27,14 +27,14 @@ class Hash
|
|
27
27
|
|
28
28
|
if RUBY_VERSION < "1.9"
|
29
29
|
|
30
|
-
#
|
31
|
-
#
|
30
|
+
# Credit: Paul Murur http://mucur.name/posts/when-is-a-set-not-a-set
|
31
|
+
# Create a hash based on the keys and values.
|
32
32
|
def hash
|
33
33
|
keys.hash + values.hash + (default ? default.hash : 0)
|
34
34
|
end
|
35
35
|
|
36
|
-
#
|
37
|
-
#
|
36
|
+
# Credit: Paul Murur http://mucur.name/posts/when-is-a-set-not-a-set
|
37
|
+
# To determine whether two hashes are the same, compare their hashes.
|
38
38
|
def eql?(other)
|
39
39
|
hash == other.hash
|
40
40
|
end
|
@@ -43,35 +43,35 @@ class Hash
|
|
43
43
|
|
44
44
|
|
45
45
|
|
46
|
-
#
|
47
|
-
#
|
46
|
+
# Entfernt alle Key-Value-Paare mit <b>nil-Keys</b> in-place.
|
47
|
+
# Tests: TestHash#test_delete
|
48
48
|
def compact_keys!
|
49
49
|
delete_if {|key, value| key.nil? }
|
50
50
|
end
|
51
51
|
|
52
52
|
|
53
|
-
#
|
54
|
-
#
|
53
|
+
# Entfernt alle alle Key-Value-Paare mit <b>nil-Values</b> in-place.
|
54
|
+
# Tests: TestHash#test_compact
|
55
55
|
def compact_values!
|
56
56
|
delete_if {|key, value| value.nil? }
|
57
57
|
end
|
58
58
|
|
59
59
|
|
60
|
-
#
|
61
|
-
#
|
60
|
+
# Entfernt das Key-Value-Paar mit einem bestimmten Key in-place.
|
61
|
+
# Rückgabe ist der modifizierte Hash (im Gegensatz zur +delete+-Methode, die das entfernte Key-Value-Paar zurückgibt! ).
|
62
62
|
def delete_key(key)
|
63
63
|
delete_if { |k,v| k == key }
|
64
64
|
end
|
65
65
|
|
66
|
-
#
|
66
|
+
# Entfernt alle Key-Value-Paare mit einem bestimmten Value in-place.
|
67
67
|
#
|
68
68
|
def delete_value(value)
|
69
69
|
delete_if { |k,v| v == value }
|
70
70
|
end
|
71
71
|
|
72
72
|
|
73
|
-
#
|
74
|
-
#
|
73
|
+
# erzwingt ein Array der Länge 1, wenn sowohl Einzelwerte als auch Arrays erlaubt sind.
|
74
|
+
# Beispiel:
|
75
75
|
# inputoptions = options.arrayize(:skip, :debug)
|
76
76
|
#
|
77
77
|
def arrayize(*keys)
|
@@ -85,7 +85,7 @@ class Hash
|
|
85
85
|
end
|
86
86
|
|
87
87
|
|
88
|
-
#
|
88
|
+
# Greift auf den Hash mit nicht-ganz-passenden Schlüsseln zu
|
89
89
|
#
|
90
90
|
def fuzzyget(key, level = 3)
|
91
91
|
try = self[key]
|
@@ -97,11 +97,11 @@ class Hash
|
|
97
97
|
end
|
98
98
|
|
99
99
|
|
100
|
-
#
|
101
|
-
#
|
102
|
-
#
|
103
|
-
#
|
104
|
-
#
|
100
|
+
# Liefert die Verteilung der size
|
101
|
+
# oder die Verteilung der class
|
102
|
+
# oder die Verteilung eines anderen Merkmals der aufgezählten Elemente.
|
103
|
+
# Siehe auch Enumerable#distribution.
|
104
|
+
# Die Keys des Hash werden ignoriert.
|
105
105
|
#
|
106
106
|
def distribution( mode = :size)
|
107
107
|
verteilung = Hash.new
|
@@ -117,7 +117,7 @@ class Hash
|
|
117
117
|
end
|
118
118
|
|
119
119
|
|
120
|
-
#
|
120
|
+
# liefert irgendein Value
|
121
121
|
#
|
122
122
|
def first
|
123
123
|
self.each do |key, value|
|
@@ -126,7 +126,7 @@ class Hash
|
|
126
126
|
end #def
|
127
127
|
|
128
128
|
|
129
|
-
#
|
129
|
+
# liefert irgendein anderes Value
|
130
130
|
#
|
131
131
|
def last
|
132
132
|
first = nil
|
data/lib/kyanite/matrix2.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
|
1
|
+
# ruby encoding: utf-8
|
2
2
|
require 'kyanite/array/matrix2'
|
data/lib/kyanite/nil.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# ruby encoding: utf-8
|
2
2
|
# [ | Kyanite | *Object* | Array | Set | Enumerable | Hash | ] | Object | String | Symbol | *Numeric* |
|
3
3
|
# [ ] | Numeric | *Integer* | Float |
|
4
4
|
#
|
@@ -15,18 +15,18 @@ class Integer
|
|
15
15
|
::Time.at(self) # ohne die Doppelpunkte sucht Ruby die Methode at in ::Time und wirft einen Error
|
16
16
|
end
|
17
17
|
|
18
|
-
#
|
19
|
-
#
|
18
|
+
# Rückgabe: self
|
19
|
+
# Test: TestKyaniteNumeric#test_integer_triviales
|
20
20
|
def to_integer; self; end
|
21
21
|
|
22
22
|
|
23
|
-
#
|
24
|
-
#
|
23
|
+
# Rückgabe: self
|
24
|
+
# Test: TestKyaniteNumeric#test_integer_triviales
|
25
25
|
def to_integer_optional; self; end
|
26
26
|
|
27
27
|
|
28
|
-
#
|
29
|
-
#
|
28
|
+
# Rückgabe: self
|
29
|
+
# Test: TestKyaniteNumeric#test_integer_triviales
|
30
30
|
def dup; self; end
|
31
31
|
|
32
32
|
end # class
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# ruby encoding: utf-8
|
2
2
|
# [ | Kyanite | *Object* | Array | Set | Enumerable | Hash | ] | Object | String | Symbol | *Numeric* |
|
3
3
|
# [ ] | *Numeric* | Integer | Float |
|
4
4
|
#
|
@@ -9,35 +9,35 @@
|
|
9
9
|
#
|
10
10
|
class Numeric
|
11
11
|
|
12
|
-
#
|
13
|
-
#
|
12
|
+
# Zahlen sind schon numerisch:
|
13
|
+
# Rückgabe self
|
14
14
|
def split_numeric
|
15
15
|
self
|
16
16
|
end
|
17
17
|
|
18
18
|
|
19
|
-
#
|
20
|
-
#
|
19
|
+
# Zahlen sind nicht empty:
|
20
|
+
# Rückgabe false
|
21
21
|
def empty?
|
22
22
|
false
|
23
23
|
end
|
24
24
|
|
25
25
|
|
26
|
-
#
|
27
|
-
#
|
26
|
+
# siehe Array#shift_complement:
|
27
|
+
# Rückgabe nil
|
28
28
|
def shift_complement
|
29
29
|
nil
|
30
30
|
end
|
31
31
|
|
32
32
|
|
33
|
-
#
|
33
|
+
# Wandelt 0 in nil um
|
34
34
|
def to_nil(*args)
|
35
35
|
return nil if self == 0
|
36
36
|
self
|
37
37
|
end
|
38
38
|
|
39
39
|
|
40
|
-
#
|
40
|
+
# nil-sicheres subtrahieren
|
41
41
|
def substract(other)
|
42
42
|
return nil if other.nil?
|
43
43
|
self - other
|
data/lib/kyanite/numeric.rb
CHANGED
data/lib/kyanite/operation.rb
CHANGED
data/lib/kyanite/optimizer.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# ruby encoding: utf-8
|
2
2
|
|
3
3
|
#
|
4
4
|
# [ | *Kyanite* | Object | Array | Set | Enumerable | Hash | ] | Kyanite | TrueClass | FalseClass | NilClass | *Div* |
|
@@ -8,9 +8,9 @@
|
|
8
8
|
# == *Optimizer*
|
9
9
|
# Auswahl von Objekten auf Basis von Scores. See TestKyaniteOptimizer for Tests and examples.
|
10
10
|
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
11
|
+
# Jedes Objekt wird per +push+ in den Optimizer geschrieben. Dabei wird auch sein Score übergeben.
|
12
|
+
# +content_max+ bzw. +content_min+ liefern das Objekt mit dem höchsten / niedrigsten Score.
|
13
|
+
# +delete_max+ bzw. +delete_min+ löschen das Objekt mit den höchsten / niedrigsten Score. Dadurch ist auch der Zugriff auf die zweiten und dritten Objekte möglich.
|
14
14
|
#
|
15
15
|
# Drei Stufen für Marshall sind denkbar:
|
16
16
|
# * kein Marshal
|
data/lib/kyanite/rake.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
|
1
|
+
# ruby encoding: utf-8
|
2
2
|
require 'kyanite/operation/rake'
|
data/lib/kyanite/range.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# ruby encoding: utf-8
|
2
2
|
require 'facets/range/combine'
|
3
3
|
require 'facets/range/within'
|
4
4
|
require 'kyanite/enumerable' # is_collection? ist für Ranges false
|
@@ -11,9 +11,9 @@ require 'kyanite/enumerable' # is_collection? ist für Ranges false
|
|
11
11
|
#
|
12
12
|
#
|
13
13
|
# Aus {Facets/Range}[http://facets.rubyforge.org/doc/api/core/classes/Range.html] eingefügt:
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
14
|
+
# umbrella(range)
|
15
|
+
# within?
|
16
|
+
# combine(range)
|
17
17
|
#
|
18
18
|
#
|
19
19
|
class Range
|
data/lib/kyanite/set.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# ruby encoding: utf-8
|
2
2
|
require 'set'
|
3
3
|
require 'kyanite/enumerable' # is_collection?
|
4
4
|
require 'kyanite/general/kernel' # silence_warnings
|
@@ -12,7 +12,7 @@ require 'kyanite/hash' # Korrektur der Methoden hash und eql?
|
|
12
12
|
#
|
13
13
|
#
|
14
14
|
# == *General* *Set*
|
15
|
-
#
|
15
|
+
# Tests and examples see TestKyaniteSet
|
16
16
|
#
|
17
17
|
#
|
18
18
|
# === Unterschiede der verschiedenen Set-Klassen
|
@@ -70,8 +70,7 @@ end
|
|
70
70
|
#
|
71
71
|
#
|
72
72
|
# == *Ordered* *Set*
|
73
|
-
#
|
74
|
-
#
|
73
|
+
# Tests and examples see TestKyaniteSet
|
75
74
|
#
|
76
75
|
# Ein OrderedSet ist geordnet, es behält die ursprüngliche Reihenfolge, wird aber nicht kontinuierlich neu sortiert.
|
77
76
|
# Es sei denn, man sorgt dafür mit Dictionary#order_by
|
@@ -144,8 +143,7 @@ end # class
|
|
144
143
|
#
|
145
144
|
#
|
146
145
|
# == *Sorted* *Set*
|
147
|
-
#
|
148
|
-
#
|
146
|
+
# Tests and examples see TestKyaniteSet
|
149
147
|
#
|
150
148
|
# Ein {SortedSet}[http://www.ruby-doc.org/core/classes/SortedSet.html] ist geordnet und sortiert. Es behält immer die Sortierung.
|
151
149
|
# Beispiele: TestKyaniteSet#test_sorted_set
|
data/lib/kyanite/string/cast.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# ruby encoding: utf-8
|
2
2
|
require 'kyanite/numeric/integer'
|
3
3
|
|
4
4
|
# [ | Kyanite | *Object* | Array | Set | Enumerable | Hash | ] | Object | *String* | Symbol | Numeric |
|
@@ -64,7 +64,7 @@ class String
|
|
64
64
|
|
65
65
|
|
66
66
|
# Get a hex representation for a char.
|
67
|
-
#
|
67
|
+
# See also String#from_x.
|
68
68
|
def to_x
|
69
69
|
hex = ''
|
70
70
|
each_byte { |byte|
|
@@ -76,8 +76,8 @@ class String
|
|
76
76
|
hex
|
77
77
|
end
|
78
78
|
|
79
|
-
#
|
80
|
-
#
|
79
|
+
# Get a char for a hex representation.
|
80
|
+
# See also String#to_x.
|
81
81
|
def from_x
|
82
82
|
str, q, first = '', 0, false
|
83
83
|
each_byte { |byte|
|
data/lib/kyanite/string/chars.rb
CHANGED
@@ -47,12 +47,12 @@ class String
|
|
47
47
|
self
|
48
48
|
end
|
49
49
|
|
50
|
-
#
|
51
|
-
#
|
52
|
-
#
|
53
|
-
#
|
50
|
+
# Reduziert den String auf ein Base53-Encoding,
|
51
|
+
# bestehend aus Großbuchstaben, Minuszeichen und zu Kleinbuchstaben umgeformten Sonderzeichen.
|
52
|
+
# Alle reduzierten Zeichen sind aber *klein*, streng genommen handelt es sich also um ein Base52-Encoding.
|
53
|
+
# Wandelt z.B. àáâăäãāåạąæảấầắằÀÁÂĂÄÃĀÅẠĄÆẢẤẦẮẰ usw. in aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa usw. um.
|
54
54
|
#
|
55
|
-
#
|
55
|
+
# See TestKyaniteStringChars for tests and examples.
|
56
56
|
#
|
57
57
|
def reduce53( options={} )
|
58
58
|
dup.reduce53!(options)
|
data/lib/kyanite/string/diff.rb
CHANGED
data/lib/kyanite/string/div.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# ruby encoding: utf-8
|
2
2
|
class String
|
3
3
|
|
4
4
|
# ---------------------------------------------------------------------------------------------------------------------------------
|
@@ -7,11 +7,11 @@ class String
|
|
7
7
|
|
8
8
|
alias :old_include? :include?
|
9
9
|
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
10
|
+
# Nimmt jetzt auch ein Array an.
|
11
|
+
# Die Array-Elemente werden ODER-verknüpft, d.h.
|
12
|
+
# include? ist true, wenn für mindestens eines der Elemente include? true ist.
|
13
|
+
# Alle Strings includen '', [] oder nil.
|
14
|
+
# Andersherum enthält nil niemals irgendwas (nil.include? => false)
|
15
15
|
def include?(input)
|
16
16
|
return true if input.nil?
|
17
17
|
return true if input.empty?
|
data/lib/kyanite/string/list.rb
CHANGED
data/lib/kyanite/string/split.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# ruby encoding: utf-8
|
2
2
|
|
3
3
|
require 'facets/string/shatter'
|
4
4
|
require 'kyanite/string/cast'
|
@@ -14,8 +14,8 @@ class String
|
|
14
14
|
# See TestKyaniteStringSplit for tests and examples.
|
15
15
|
#
|
16
16
|
# Aus {Facets/String}[http://facets.rubyforge.org/doc/api/core/classes/String.html]eingefügt:
|
17
|
-
#
|
18
|
-
#
|
17
|
+
# *shatter*(re)
|
18
|
+
# Breaks a string up into an array based on a regular expression. Similar to +scan+, but includes the matches.
|
19
19
|
|
20
20
|
|
21
21
|
|