kyanite 0.6.1 → 0.7.0

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.
Files changed (86) hide show
  1. data/Div +6 -32
  2. data/{History.txt → History.rdoc} +8 -0
  3. data/{License.txt → License.rdoc} +0 -0
  4. data/Manifest.txt +6 -21
  5. data/README.rdoc +44 -0
  6. data/Rakefile.rb +19 -68
  7. data/console.rb +2 -4
  8. data/lib/kyanite.rb +151 -14
  9. data/lib/kyanite/array.rb +127 -4
  10. data/lib/kyanite/basics.rb +3 -7
  11. data/lib/kyanite/dictionary.rb +19 -21
  12. data/lib/kyanite/enumerable/enumerable_enumerables.rb +22 -24
  13. data/lib/kyanite/enumerable/enumerable_numerics.rb +51 -49
  14. data/lib/kyanite/enumerable/enumerable_strings.rb +18 -25
  15. data/lib/kyanite/enumerable/structure.rb +46 -58
  16. data/lib/kyanite/general/callerutils.rb +30 -28
  17. data/lib/kyanite/general/classutils.rb +73 -63
  18. data/lib/kyanite/general/kernel.rb +45 -64
  19. data/lib/kyanite/general/object.rb +22 -46
  20. data/lib/kyanite/general/true_false.rb +33 -27
  21. data/lib/kyanite/general/undoable.rb +12 -16
  22. data/lib/kyanite/hash.rb +63 -58
  23. data/lib/kyanite/numeric.rb +14 -1
  24. data/lib/kyanite/numeric/float.rb +32 -22
  25. data/lib/kyanite/numeric/integer.rb +12 -20
  26. data/lib/kyanite/optimizer.rb +41 -24
  27. data/lib/kyanite/range.rb +42 -22
  28. data/lib/kyanite/set.rb +56 -63
  29. data/lib/kyanite/string.rb +1 -2
  30. data/lib/kyanite/string/cast.rb +61 -37
  31. data/lib/kyanite/string/chars.rb +66 -36
  32. data/lib/kyanite/string/chars_const.rb +4 -3
  33. data/lib/kyanite/string/diff.rb +64 -34
  34. data/lib/kyanite/string/include.rb +16 -9
  35. data/lib/kyanite/string/list.rb +38 -8
  36. data/lib/kyanite/string/misc.rb +64 -0
  37. data/lib/kyanite/string/nested.rb +39 -22
  38. data/lib/kyanite/string/random.rb +117 -47
  39. data/lib/kyanite/string/split.rb +84 -45
  40. data/lib/kyanite/symbol.rb +30 -21
  41. data/lib/kyanite/tree.rb +33 -28
  42. data/test/_start_all.rb +18 -15
  43. data/test/array/test_array.rb +5 -7
  44. data/test/enumerable/test_enumerable_enumerables.rb +11 -15
  45. data/test/enumerable/test_enumerable_numerics.rb +50 -54
  46. data/test/enumerable/test_enumerable_strings.rb +8 -11
  47. data/test/enumerable/test_structure.rb +6 -8
  48. data/test/general/test_classutils.rb +9 -9
  49. data/test/general/test_object.rb +4 -5
  50. data/test/general/test_true_false.rb +4 -5
  51. data/test/numeric/test_numeric_integer.rb +6 -6
  52. data/test/string/test_cast.rb +4 -5
  53. data/test/string/test_chars.rb +6 -7
  54. data/test/string/test_diff.rb +4 -5
  55. data/test/string/test_list.rb +4 -5
  56. data/test/string/test_misc.rb +58 -0
  57. data/test/string/test_nested.rb +4 -5
  58. data/test/string/test_split.rb +10 -5
  59. data/test/test_dictionary.rb +4 -6
  60. data/test/test_hash.rb +5 -7
  61. data/test/test_optimizer.rb +4 -5
  62. data/test/test_range.rb +8 -9
  63. data/test/test_set.rb +7 -7
  64. data/test/test_tree.rb +7 -10
  65. data/version.rb +8 -0
  66. metadata +32 -33
  67. data/README.txt +0 -47
  68. data/lib/kyanite/array/array.rb +0 -140
  69. data/lib/kyanite/array/array2.rb +0 -142
  70. data/lib/kyanite/array/matrix2.rb +0 -120
  71. data/lib/kyanite/hoe.rb +0 -2
  72. data/lib/kyanite/matrix2.rb +0 -2
  73. data/lib/kyanite/numeric/numeric.rb +0 -54
  74. data/lib/kyanite/operation.rb +0 -5
  75. data/lib/kyanite/operation/call_tracker.rb +0 -69
  76. data/lib/kyanite/operation/hoe.rb +0 -12
  77. data/lib/kyanite/operation/rake.rb +0 -298
  78. data/lib/kyanite/operation/regexp.rb +0 -28
  79. data/lib/kyanite/operation/unit_test.rb +0 -50
  80. data/lib/kyanite/rake.rb +0 -2
  81. data/lib/kyanite/smart_load_path.rb +0 -6
  82. data/lib/kyanite/string/div.rb +0 -28
  83. data/lib/kyanite/string/mgsub.rb +0 -43
  84. data/lib/kyanite/unit_test.rb +0 -2
  85. data/test/array/test_matrix2.rb +0 -166
  86. data/test/string/test_mgsub.rb +0 -58
@@ -1,24 +1,20 @@
1
- # ruby encoding: utf-8
1
+ # ruby encoding: utf-8
2
2
  # ü
3
+ if $0 == __FILE__
4
+ require 'drumherum'
5
+ smart_init
6
+ end
7
+
3
8
 
4
- # [ | Kyanite | Object | Array | Set | *Enumerable* | Hash | ] | Enumerable | EnumerableNumerics | *EnumerableStrings* | EnumerableEnumerables |
5
- # ---
6
- #
7
- #
8
- # == *Enumeration* *Of* *Strings*
9
- # See TestKyaniteEnumerableStrings for tests and examples.
10
- # See ArrayOfStrings for an Array with modul EnumerableStrings included.
11
- #
12
- #
13
- module EnumerableStrings
14
9
 
15
10
 
16
- # Bsp.:
11
+ # @!macro enum_of_strings
12
+ module EnumerableStrings
13
+
14
+ # Delete every element from the front with is identical with the back -- leave the significant middle part.
15
+ # Example:
17
16
  # ['lut', 'lutm', 'lutmi', 'lutmil', 'lutmila', 'lutrika', 'lutrik', 'lutri', 'lutr', 'lut'].palindrom_rumpf =>
18
17
  # ['lutm', 'lutmi', 'lutmil', 'lutmila', 'lutrika', 'lutrik', 'lutri', 'lutr']
19
- # d.h. vorne und hinten wird alles Gleiche weggestrichen.
20
- #
21
- # Tests and examples see TestKyaniteEnumerableStrings.
22
18
  #
23
19
  def palindrom_rumpf
24
20
  result = self.dup
@@ -38,26 +34,23 @@ end
38
34
 
39
35
 
40
36
 
41
- # [ | Kyanite | Object | *Array* | Set | Enumerable | Hash | ] | Array | ArrayOfNumerics | *ArrayOfStrings* | ArrayOfEnumerables | Range |
42
- # ---
43
- #
44
- #
45
- # == *Array* *Of* *Strings*
46
- # An ArrayOfstrings is an Array with modul EnumerableStrings included.
47
- # See TestKyaniteEnumerableStrings for tests and examples.
48
- #
37
+
38
+ # @!macro enum_of_strings
49
39
  class ArrayOfStrings < Array
50
40
  include EnumerableStrings
51
41
  end
52
42
 
53
-
43
+
54
44
 
55
45
  class Array
56
46
 
57
- # Liefert ein ArrayOfStrings (das ist ein Array mit inkludiertem Modul EnumerableStrings)
47
+ # @!group Cast
48
+ # Returns {ArrayOfStrings} (this is an {Array} with modul {EnumerableStrings} included)
49
+ # @return [ArrayOfStrings]
58
50
  def to_array_of_strings
59
51
  ArrayOfStrings.new(self)
60
52
  end
53
+ #@!endgroup
61
54
 
62
55
  end
63
56
 
@@ -1,10 +1,11 @@
1
1
  # ruby encoding: utf-8
2
- # ü
2
+
3
3
  if $0 == __FILE__
4
- require File.join(File.dirname(__FILE__), '..', '..', '..', 'smart_load_path.rb' )
5
- smart_load_path
4
+ require 'drumherum'
5
+ smart_init
6
6
  end
7
7
 
8
+
8
9
  require 'kyanite/general/object'
9
10
  require 'kyanite/array/array'
10
11
  require 'kyanite/dictionary'
@@ -14,73 +15,63 @@ require 'kyanite/dictionary'
14
15
 
15
16
  class Object
16
17
 
17
- # Enthält ein Objekt mehrere Objekte?
18
- # String und Range gelten nicht als Collection.
19
- # See TestKyaniteEnumerableStructure for tests and examples.
18
+ # @!macro [new] is_collection
19
+ # -- Defined for all objects: Do I contain multiple objects? {String} and {Range} are not considered as collection.
20
+ #
21
+ # Tests and examples {TestKyaniteEnumerableStructure#test_is_collection here}.
22
+
23
+ # +false+
24
+ # @!macro is_collection
25
+ # @return [false]
20
26
  def is_collection?; false; end
21
27
 
22
28
  end
23
29
 
24
30
 
25
- module Enumerable
31
+ class Range
26
32
 
27
- # Enthält ein Objekt mehrere Objekte?
28
- # Rückgabe: true
29
- # String und Range gelten nicht als Collection.
30
- # See TestKyaniteEnumerableStructure for tests and examples.
31
- def is_collection?; true; end
33
+ # +false+
34
+ # @!macro is_collection
35
+ # @return [false]
36
+ def is_collection?; false; end
32
37
 
33
38
  end
34
39
 
35
40
 
36
- class String
37
41
 
38
- # ---------------------------------------------------------------------------------------------------------------------------------
39
- # :section: Structure
40
- #
42
+ class String
41
43
 
42
- # Enthält ein Objekt mehrere Objekte?
43
- # Rückgabe: false
44
- # String und Range gelten nicht als Collection.
45
- # See TestKyaniteEnumerableStructure for tests and examples.
44
+ # @!group Miscellaneous
45
+ # +false+
46
+ # @!macro is_collection
47
+ # @return [false]
46
48
  def is_collection?; false; end
47
-
48
-
49
+ # @!endgroup
49
50
  end
50
51
 
51
52
 
52
- class Range
53
-
54
- # Enthält ein Objekt mehrere Objekte?
55
- # Rückgabe: false
56
- # String und Range gelten nicht als Collection.
57
- # See TestKyaniteEnumerableStructure for tests and examples.
58
- def is_collection?; false; end
53
+ # @!group Structure Reflection
59
54
 
60
- end
61
-
55
+ module Enumerable
62
56
 
57
+ # @!macro is_collection
58
+ # +true+
59
+ # @!macro is_collection
60
+ # @return [true]
61
+ def is_collection?; true; end
62
+
63
+ end
63
64
 
64
65
 
65
66
 
66
67
 
67
68
 
68
- # [ | Kyanite | Object | Array | Set | *Enumerable* | Hash | ] | *Enumerable* | EnumerableNumerics | EnumerableStrings | EnumerableEnumerables |
69
- # ---
70
- #
71
- #
72
- # == *General* *Enumerations*
73
- # See TestKyaniteEnumerableStructure for tests and examples.
74
- #
75
- #
69
+ # @!macro enumerable
76
70
  module Enumerable
77
71
 
78
- # Liefert die Verteilung der size
79
- # oder die Verteilung der class
80
- # oder die Verteilung eines anderen Merkmals der aufgezählten Elemente.
81
- # die Methode gibt es auch als Hash#distribution.
82
- # See TestKyaniteEnumerableStructure for tests and examples.
83
- #
72
+ # Returns the distribution of +size+, +class+ or any other characteristics of the enumerated elements.
73
+ # See also {Hash#distribution}. Tests and examples {TestKyaniteEnumerableStructure#test_distribution_class here}.
74
+ # @return [Array]
84
75
  def distribution( mode = :size)
85
76
  verteilung = Hash.new
86
77
  each do | element |
@@ -96,20 +87,17 @@ module Enumerable
96
87
 
97
88
 
98
89
 
99
-
100
-
101
-
102
- # Was für Objekte beinhaltet die Collection?
103
- # Liefert die Klasse der Contentelemente, oder <tt>Object</tt> wenn es verschiedene sind.
104
- #
105
- # Parameter ist die Genauigkeit, mit der der Inhalt geprüft wird.
106
- # :precision => 1 nur das erste Element wird geprüft
107
- # :precision => 2 das erste und das letzte Element werden geprüft (STANDARD)
108
- # :precision => :all alle Elemente werden geprüft
109
- # :ignore_nil => true NilClass wird nicht aufgeführt (STANDARD)
110
- # :ignore_nil => false NilClass wird mit aufgeführt
90
+ # What kind of objects contains the collection?
91
+ # Returns the class of content elements, or +Object+ if there are several.
92
+ #
93
+ # Parameters is the accuracy with which the content is checked.
94
+ # [:precision => 1] only the first element is checked
95
+ # [:precision => 2] the first and the last elements are checked (STANDARD)
96
+ # [:precision => :all] every element is checked
97
+ # [:ignore_nil => true] NilClass will not be listed (STANDARD)
98
+ # [:ignore_nil => false] NilClass will be listed
111
99
  #
112
- # See TestKyaniteEnumerableStructure for tests and examples.
100
+ # Tests and examples {TestKyaniteEnumerableStructure#test_contentclass_mono here}.
113
101
  #
114
102
  def contentclass( options={} )
115
103
  precision = options[:precision] || 2
@@ -1,30 +1,31 @@
1
1
  # ruby encoding: utf-8
2
+ # ü
3
+ if $0 == __FILE__
4
+ require 'drumherum'
5
+ smart_init
6
+ end
7
+
2
8
  require 'kyanite/string/include'
3
9
 
4
10
 
5
11
 
6
- # [ | Kyanite | *Object* | Array | Set | Enumerable | Hash | ] | *Object* | String | Symbol | Numeric |
7
- # [ ] | Object | KKernel | *CallerUtils* | Undoable | Class |
8
- #
9
- # ---
10
- #
11
- #
12
- # == *Tools* *for* Kernel#caller
13
- #
12
+
13
+ # @!macro caller_utils
14
14
  class CallerUtils
15
15
 
16
- # Untersucht den Call-Stack. Liefert die Größe des Stacks oder den letzten Eintrag.
16
+ # Examines the call stack, returns the size of the stack, or the last caller.
17
+ # @param options [Hash] Options
18
+ # @option options [String, Array] :skip Ignore caller that contain the specified fragment
19
+ # @option options [Symbol] :mode What kind of result is to be returned? +:caller+ (default) returns the caller, +:size+ returns the size of the call stack.
17
20
  #
18
- # Options:
19
- # :skip Ignoriere caller, die das angegebene Fragment enthalten (String oder Array)
20
- # :mode Welche Art von Ergebnis soll geliefert werden?
21
- # :caller (Standard) liefert den Caller,
22
- # :size liefert die Größe das Call-Stacks
21
+ # Example:
22
+ # CallerUtils.mycaller(:skip => ['ruby\gems', 'ruby/gems', 'test/unit'])
23
+ # => "C:/Ruby-Projekte/kyanite/lib/kyanite/general/callerutils.rb:110:in `<main>'"
23
24
  #
24
- # Beispiel:
25
- # CallerUtils.mycaller(:skip => ['perception', 'ruby\gems', 'ruby/gems', 'test/unit'])
26
- # => "R:/_Eigene_Projekte_unter_SVN/kyanite/lib/kyanite/general/callerutils.rb:100"
27
- #
25
+ # CallerUtils.mycaller(:skip => ['ruby\gems', 'ruby/gems', 'test/unit'], :mode=> :size)
26
+ # => 1
27
+ #
28
+ # @return [String, Integer]
28
29
  def self.mycaller(options={})
29
30
  skip = options[:skip] || []
30
31
  skip = [skip] if skip.kind_of?(String)
@@ -53,14 +54,14 @@ class CallerUtils
53
54
 
54
55
 
55
56
 
56
- # Ermittelt das Hauptverzeichnis eines Callers auf heuristischem Wege.
57
- # Der Name des Hauptverzeichnisses entspricht meist dem Namen der Applikation oder Library.
58
- #
59
- # Beispiel:
60
- # my_caller = CallerUtils.mycaller(:skip => ['perception', 'ruby\gems', 'ruby/gems', 'test/unit'])
57
+
58
+ # Determines the root directory of a caller on heuristic way. The name of the main directory is usually the name of the application or library.
59
+ # Example:
60
+ # my_caller = CallerUtils.mycaller(:skip => ['ruby\gems', 'ruby/gems', 'test/unit'])
61
61
  # CallerUtils.mycaller_maindir(my_caller)
62
- # => "R:/_Eigene_Projekte_unter_SVN/kyanite"
62
+ # => "C:/Ruby-Projekte/kyanite"
63
63
  #
64
+ # @return [String]
64
65
  def self.mycaller_maindir(mycaller)
65
66
  dir_caller =File.dirname(mycaller)
66
67
  array_caller = dir_caller.split('/')
@@ -109,10 +110,11 @@ if $0 == __FILE__
109
110
 
110
111
 
111
112
 
112
- require 'pp'
113
- my_caller = CallerUtils.mycaller(:skip => ['perception', 'ruby\gems', 'ruby/gems', 'test/unit'])
114
- my_maindir = CallerUtils.mycaller_maindir(my_caller) if my_caller
115
- pp my_maindir
113
+
114
+ my_caller = CallerUtils.mycaller(:skip => ['ruby\gems', 'ruby/gems', 'test/unit'])
115
+ #puts my_caller
116
+ puts CallerUtils.mycaller_maindir(my_caller) if my_caller
117
+
116
118
 
117
119
 
118
120
 
@@ -1,26 +1,34 @@
1
1
  # ruby encoding: utf-8
2
+ # ü
3
+ if $0 == __FILE__
4
+ require 'drumherum'
5
+ smart_init
6
+ end
7
+
2
8
 
3
- require 'facets/kernel/singleton_class' # Easy access to an object‘s "special" class, otherwise known as it‘s eigen or meta class.
4
- require 'facets/class/descendants' # Methode descendants
9
+ # @!group Class Utils
5
10
 
11
+ require 'facets/class/descendants' # Methode descendants
12
+ # require 'facets/kernel/singleton_class' # Easy access to an object‘s "special" class, otherwise known as it‘s eigen or meta class.
6
13
 
7
- # [ | Kyanite | *Object* | Array | Set | Enumerable | Hash | ] | *Object* | String | Symbol | Numeric |
8
- # [ ] | Object | KKernel | CallerUtils | Undoable | *Class* |
14
+ # =================================================================================================================
9
15
  #
10
- # ---
16
+ # @!macro class_utils
11
17
  #
12
- # == *Class* *Utils*
13
- # See TestKyaniteClassutils for tests and examples.
18
+ # === Added from {http://rubyworks.github.com/rubyfaux/?doc=http://rubyworks.github.com/facets/docs/facets-2.9.3/core.json#api-class-Class Facets Class}:
19
+ # [+descendants(generations=-1))+] List all descedents of this class.
14
20
  #
15
21
  class Class
16
22
 
17
- # Vergleichsoperator: Alphabetisch.
23
+ # Comparison operator (alphabetical)
24
+ # @return [Integer] 1, 0, -1
18
25
  def <=>(other)
19
26
  ( ( self.to_s ) <=> ( other.to_s ) )
20
27
  end
21
28
 
22
29
 
23
- # Unscharfer Vergleich zweier Klassen, z.B. für Tests
30
+ # Fuzzy comparison of two classes (useful for tests)
31
+ # @return [Boolean]
24
32
  def =~(other)
25
33
  return true if self == other
26
34
  return true if self.descendants.include?(other)
@@ -28,21 +36,13 @@ class Class
28
36
  return false
29
37
  end
30
38
 
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
- #
39
+ # (see String#to_class)
36
40
  def to_class
37
41
  self
38
42
  end
39
43
 
40
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
+ # (see String#to_classname)
46
46
  def to_classname
47
47
  self.to_s.demodulize.underscore
48
48
  end
@@ -52,58 +52,32 @@ end # class
52
52
 
53
53
 
54
54
 
55
-
56
-
57
- class Symbol
58
-
59
- # Wandelt ein Symbol in einen Klassennamen, der nur Kleinbuchstaben enthält.
60
- # Siehe String#to_classname
61
- # Tests and examples see TestKyaniteClassutils
62
- #
63
- def to_classname
64
- self.to_s.to_classname
65
- end
66
-
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
- #
72
- def to_class
73
- self.to_s.to_class
74
- end
75
-
76
- end # class
55
+
77
56
 
78
57
 
58
+ class String
79
59
 
80
60
 
81
-
82
-
83
-
84
- class String
85
61
 
86
- # ---------------------------------------------------------------------------------------------------------------------------------
87
- # :section: Class Utils
88
- # See TestKyaniteClassutils for tests and examples.
89
- #
90
-
91
-
92
- # Wandelt einen String in einen Klassennamen, der nur Kleinbuchstaben enthält.
93
- # 'MeinModul::EineKlasse' => 'eine_klasse'
62
+ # Converts to a class name , the reverse of {String#to_class to_class}.
94
63
  #
95
- # Tests and examples see TestKyaniteClassutils
64
+ # classes {Class}, {Symbol}, {String}. The class name will contain only lowercase letters.
65
+ # 'MyModul::MyClass' => 'my_class'
66
+ #
67
+ # Tests and examples {TestKyaniteClassutils here}.
68
+ # @return [String]
96
69
  #
97
70
  def to_classname
98
71
  self.demodulize.underscore
99
72
  end
100
73
 
101
74
 
102
-
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
75
+ # Converts to a class, the reverse of {String#to_classname to_classname}
76
+ #
77
+ # Defined for classes {Class}, {Symbol}, {String}. Accepts both CamelCase and down_case.
78
+ #
79
+ # Tests and examples {TestKyaniteClassutils here}.
80
+ # @return [Class]
107
81
  #
108
82
  def to_class
109
83
  self.camelize.constantize
@@ -122,6 +96,7 @@ class String
122
96
  # "ActiveRecord::Errors".underscore # => active_record/errors
123
97
  # From ActiveSupport, Copyright (c) 2005 David Heinemeier Hansson. See License.txt.
124
98
  #
99
+ # @return [String]
125
100
  def underscore
126
101
  self.gsub(/::/, '/').
127
102
  gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
@@ -144,6 +119,7 @@ class String
144
119
  # "active_record/errors".camelize(:lower) # => "activeRecord::Errors"
145
120
  # From ActiveSupport, Copyright (c) 2005 David Heinemeier Hansson. See License.txt.
146
121
  #
122
+ # @return [String]
147
123
  def camelize(first_letter_in_uppercase = true)
148
124
  if first_letter_in_uppercase
149
125
  self.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
@@ -160,6 +136,7 @@ class String
160
136
  # "Inflections".demodulize # => "Inflections"
161
137
  # From ActiveSupport, Copyright (c) 2005 David Heinemeier Hansson. See License.txt.
162
138
  #
139
+ # @return [String]
163
140
  def demodulize
164
141
  self.gsub(/^.*::/, '')
165
142
  end
@@ -185,6 +162,7 @@ class String
185
162
  # unknown.
186
163
  # From ActiveSupport, Copyright (c) 2005 David Heinemeier Hansson. See License.txt.
187
164
  #
165
+ # @return [Class]
188
166
  def constantize
189
167
  unless /\A(?:::)?([A-Z]\w*(?:::[A-Z]\w*)*)\z/ =~ self
190
168
  raise NameError, "#{self.inspect} is not a valid constant name!"
@@ -193,14 +171,46 @@ class String
193
171
  Object.module_eval("::#{$1}", __FILE__, __LINE__)
194
172
  end
195
173
 
196
- end # class
174
+ end # String
175
+
176
+
177
+
178
+
179
+
180
+
197
181
 
198
- if defined? TransparentNil
182
+ # =================================================================================================================
183
+ #
184
+ # @!macro class_utils
185
+ #
186
+ class Symbol
187
+
188
+ # (see String#to_classname)
189
+ def to_classname
190
+ self.to_s.to_classname
191
+ end
192
+
193
+ # (see String#to_class)
194
+ def to_class
195
+ self.to_s.to_class
196
+ end
197
+
198
+ end # Symbol
199
+
200
+
201
+
202
+
203
+
204
+ # =================================================================================================================
205
+ # @!macro class_utils
206
+ #
199
207
  class NilClass
200
208
 
201
- # Rückgabe: Leerer String
209
+ # @return [String] empty String
202
210
  def to_classname; ''; end
203
211
 
212
+ # @!group return nil
213
+
204
214
  def camelize; nil; end
205
215
  def constantize; nil; end
206
216
  def demodulize; nil; end
@@ -208,7 +218,7 @@ if defined? TransparentNil
208
218
  def underscore; nil; end
209
219
 
210
220
  end
211
- end
221
+
212
222
 
213
223
 
214
224