kyanite 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
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,33 +1,29 @@
1
1
  # ruby encoding: utf-8
2
- require 'facets/timer'
3
- require 'rbconfig'
4
-
5
- unless defined? WINDOWS
6
- WINDOWS = /djgpp|(cyg|ms|bcc)win|mingw/ =~ RUBY_PLATFORM ? RUBY_PLATFORM : false
7
- end
8
-
9
- unless defined? RUBYDIR
10
- RUBYDIR = RbConfig::CONFIG['prefix']
11
- # puts "rubydir=" + RUBYDIR
2
+ # ü
3
+ if $0 == __FILE__
4
+ require 'drumherum'
5
+ smart_init
12
6
  end
13
7
 
8
+ require 'facets/timer'
14
9
 
15
10
 
16
11
 
17
- # [ | Kyanite | *Object* | Array | Set | Enumerable | Hash | ] | *Object* | String | Symbol | Numeric |
18
- # [ ] | Object | *KKernel* | CallerUtils | Undoable | Class |
19
- #
20
- # ---
21
- #
22
- #
23
- # == *General* *Tools*
24
- #
25
- #
12
+ # @!macro object
26
13
  module KKernel
27
14
 
28
- # Wiederholt einen Block so lange, bis die Zeit abgelaufen ist.
29
- # Liefert die Anzahl der Durchläufe, die in dieser Zeit möglich waren.
30
- # Alle Exceptions werden abgefangen (=> fehlerhafte Blöcke scheinen schneller zu laufen)
15
+ # @!macro [new] seconds
16
+ # Repeats a block until the time is up.
17
+ # Returns the number of passes. All Exceptions are caught (=> bad blocks seem to run faster).
18
+ # Example (using {Numeric}):
19
+ # 3.seconds do
20
+ # puts Time.now.inspect
21
+ # end
22
+ # Example (using {KKernel}):
23
+ # repeat_n_seconds 3 do
24
+ # puts Time.now.inspect
25
+ # end
26
+ #
31
27
  def repeat_n_seconds( n=1, &block )
32
28
  timer = Timer.new(n)
33
29
  begin
@@ -35,7 +31,7 @@ module KKernel
35
31
  count = 0
36
32
  until false
37
33
  count += 1
38
- yield block
34
+ yield block if block
39
35
  end
40
36
  timer.stop
41
37
  rescue TimeoutError
@@ -50,9 +46,15 @@ module KKernel
50
46
 
51
47
 
52
48
 
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
49
+
50
+
51
+ # Silence all Ruby warnings for the following block. Useful to override constants.
52
+ # Example:
53
+ # TEST = 1
54
+ # silence_warnings do
55
+ # TEST = 2
56
+ # end
57
+ #
56
58
  def silence_warnings
57
59
  old_verbose, $VERBOSE = $VERBOSE, nil
58
60
  yield
@@ -61,58 +63,37 @@ module KKernel
61
63
  end
62
64
 
63
65
 
64
- # Vereinfacht die require-Statements in den Tests bei der Entwicklung von Libraries.
65
- # Beim lokalen Aufruf eines einzelnen Tests wird die lokale Version der Library verwendet, nicht die installierte gem.
66
- # Verwendung:
67
- # if $0 == __FILE__
68
- # require 'kyanite/smart_load_path'
69
- # smart_load_path
70
- # end
71
- # require 'mygemproject'
72
- #
73
- def smart_load_path(__file__ = nil)
74
- __file__ = caller[0] unless __file__
75
- dir_caller =File.dirname(__file__)
76
-
77
- #puts "smart_load_path " + dir_caller
78
-
79
- patharray = dir_caller.split('/')
80
- patharray = dir_caller.split("\\") if patharray.size == 1
81
- # libpath = File.join(patharray)
82
- patharray.size.times do |i|
83
- break if File.directory?( File.join(patharray, 'lib') )
84
- patharray << '..'
85
- end
86
- newpath = File.join(patharray,'lib')
87
- if $:.include?(newpath)
88
- return false
89
- else
90
- $:.unshift(newpath)
91
- return true
92
- end
93
-
94
- end #def
66
+
95
67
 
96
68
 
97
- end # module
69
+ end
98
70
 
99
71
  class Object
100
72
  include KKernel
101
73
  end
102
74
 
75
+ class Numeric
76
+
77
+ # @!macro seconds
78
+ def seconds( &block )
79
+ repeat_n_seconds( self ) do
80
+ yield block if block
81
+ end
82
+ end
83
+
84
+ end
85
+
103
86
 
104
87
  # ---------------------------------------------------------
105
88
  # Ausprobieren
106
89
  #
107
90
  if $0 == __FILE__
108
91
 
109
- # pp RUBYDIR
110
-
111
- smart_load_path(__FILE__)
112
- $LOAD_PATH.each do |path|
113
- puts path
92
+ TEST = 1
93
+ silence_warnings do
94
+ TEST = 2
114
95
  end
115
-
96
+ puts TEST
116
97
  end
117
98
 
118
99
 
@@ -1,46 +1,39 @@
1
1
  # ruby encoding: utf-8
2
+ # ü
3
+ if $0 == __FILE__
4
+ require 'drumherum'
5
+ smart_init
6
+ end
7
+
2
8
 
3
9
 
4
- # [ | Kyanite | *Object* | Array | Set | Enumerable | Hash | ] | *Object* | String | Symbol | Numeric |
5
- # [ ] | *Object* | KKernel | CallerUtils | Undoable | Class |
6
- #
7
- # ---
8
- #
9
- #
10
- # == *For* *All* *Objects*
11
- # Tests and examples see TestKyaniteObject
12
- #
13
- #
10
+ # @!macro object
14
11
  class Object
15
12
 
16
- # <tt> false </tt>
17
- #
18
- # Tests and examples see TestKyaniteObject
19
- #
13
+ # Returns +false+
14
+ # @return [false]
20
15
  def blank?
21
16
  false
22
17
  end
23
18
 
24
19
 
25
- # Quelle: Facets http://facets.rubyforge.org/quick/rdoc/core/classes/Kernel.html#M000379
26
- #
20
+
21
+ # Like +respond_to?+ but returns the result of the call if it does indeed respond.
22
+ # See {http://rubyworks.github.com/rubyfaux/?doc=http://rubyworks.github.com/facets/docs/facets-2.9.3/core.json#api-module-Kernel/api-method-Kernel-h-respond Facets +Kernel#respond+}.
27
23
  def respond(sym, *args)
28
24
  return nil if not respond_to?(sym)
29
25
  send(sym, *args)
30
26
  end
31
27
 
32
28
 
33
- # Alternative zu Object#dup. Dupliziert auch Unterobjekte. Langsam.
34
- # Wird z.B. für Undo-Operationen verwendet, siehe Modul Undoable.
35
- #
29
+ # Slow but in-depth alternative to +dup+. Also duplicates sub-objects. Is e.g. for undo operations used, see module {Undoable}.
36
30
  def deep_copy
37
31
  Marshal.load( Marshal.dump( self ) )
38
32
  end
39
33
 
40
34
 
41
- # Ist ein Objekt numerisch?
42
- #
43
- # Tests and examples see TestKyaniteObject
35
+ # Is the object numeric?
36
+ # Tests see {TestKyaniteObject here}.
44
37
  #
45
38
  def is_numeric?
46
39
  Float self
@@ -48,30 +41,13 @@ class Object
48
41
  false
49
42
  end
50
43
 
51
-
52
- # <tt> false </tt>
44
+ # Returns +false+
45
+ # @return [false]
53
46
  def empty?
54
47
  false
55
48
  end
56
49
 
57
-
58
-
59
-
60
-
61
- # Liefert nil, wenn die Condition erfüllt ist. Sonst self.
62
- #
63
- def to_nil(condition = :empty)
64
- return nil if self.respond(condition.to_s + '?')
65
- return self
66
- end
67
-
68
-
69
- # Liefert nil, wenn die Condition nicht erfüllt ist. Sonst self.
70
- #
71
- def to_nil_unless(condition = :empty)
72
- return nil unless self.respond(condition.to_s + '?')
73
- return self
74
- end
50
+
75
51
 
76
52
 
77
53
  # Findet den Namen einer Ruby-Konstanten anhand seines Wertes.
@@ -88,14 +64,14 @@ end
88
64
  if defined? TransparentNil
89
65
  class NilClass
90
66
 
91
- # Rückgabe: false
67
+ # +false+
68
+ # @return [false]
92
69
  def blank?; false; end
93
70
 
94
- # Rückgabe: false
71
+ # +false+
72
+ # @return [false]
95
73
  def is_numeric?; false; end
96
74
 
97
- def to_nil; nil; end
98
- def to_nil_unless(*a); nil; end
99
75
  def name_of_constant(*a); nil; end
100
76
  end
101
77
  end
@@ -1,34 +1,40 @@
1
1
  # ruby encoding: utf-8
2
- # [ | *Kyanite* | Object | Array | Set | Enumerable | Hash | ] | Kyanite | *TrueClass* | FalseClass | NilClass | Div |
3
- #
4
- # ---
5
- #
6
- # == *True*
7
- #
8
- #
2
+ # ü
3
+ if $0 == __FILE__
4
+ require 'drumherum'
5
+ smart_init
6
+ end
7
+
8
+
9
+ # @!macro true_false
9
10
  class TrueClass
10
11
 
11
12
 
12
- # Rückgabe: 1
13
+ # Returns +1+
14
+ # @return [1]
13
15
  def to_i; 1; end
14
16
 
15
17
 
16
- # Rückgabe: self
18
+ # Returns +self+
19
+ # @return [self]
17
20
  def strip; self; end
18
21
 
19
22
 
20
- # Rückgabe: self
23
+ # Returns +self+
24
+ # @return [self]
21
25
  def dup; self; end
26
+
22
27
 
23
-
24
- # see TestKyaniteTrueFalse#test_raumschiff_operator for tests
28
+ # Defines true <=> true, true <=> false, false <=> true, false <=> false.
29
+ # See Tests {TestKyaniteTrueFalse#test_raumschiff_operator here}.
25
30
  def <=>(other)
26
31
  return 1 if ! other
27
32
  return 0
28
33
  end
29
34
 
30
35
 
31
- # Rückgabe: false
36
+ # Returns +false+
37
+ # @return [false]
32
38
  def blank?; false; end
33
39
 
34
40
 
@@ -37,33 +43,33 @@ end # class
37
43
 
38
44
 
39
45
 
40
- # [ | *Kyanite* | Object | Array | Set | Enumerable | Hash | ] | Kyanite | TrueClass | *FalseClass* | NilClass | Div |
41
- #
42
- # ---
43
- #
44
- # == *False*
45
- #
46
+ # @!macro true_false
46
47
  class FalseClass
47
48
 
48
- # Rückgabe: 0
49
+ # Returns +0+
50
+ # @return [0]
49
51
  def to_i; 0; end
50
-
51
- # Rückgabe: self
52
+
53
+
54
+ # Returns +self+
55
+ # @return [self]
52
56
  def strip; self; end
57
+
53
58
 
54
- # Rückgabe: self
59
+ # Returns +self+
60
+ # @return [self]
55
61
  def dup; self; end
62
+
56
63
 
57
- # see TestKyaniteTrueFalse#test_raumschiff_operator for tests
64
+ # (see TrueClass#<=>)
58
65
  def <=>(other)
59
66
  return -1 if other
60
67
  return 0
61
68
  end
62
69
 
63
70
 
64
- # umdefiniert!
65
- #
66
- # TestKyaniteObject#test_blank
71
+ # Returns +false+
72
+ # @return [self]
67
73
  def blank?; self; end
68
74
 
69
75
 
@@ -1,20 +1,18 @@
1
1
  # ruby encoding: utf-8
2
+ # ü
3
+ if $0 == __FILE__
4
+ require 'drumherum'
5
+ smart_init
6
+ end
2
7
 
3
- # [ | Kyanite | *Object* | Array | Set | Enumerable | Hash | ] | *Object* | String | Symbol | Numeric | Class |
4
- # [ ] | Object | KKernel | CallerUtils | *Undoable* | Class |
5
- #
6
- # ---
7
- #
8
- #
9
- # == *Undo*
10
- #
11
- #
8
+
9
+ # @!macro undoable
12
10
  module Undoable
13
11
 
14
12
  @@undoable_history = Hash.new
15
13
 
16
- # Speichert ein Objekt.
17
- # Verwendet standardmäßig Object#dup. Für komplexere Objekte muss allerdings Object#deep_copy genutzt werden.
14
+ # Saves an object.
15
+ # @param method [Symbol] method to use. Default is +:dup+. For more complex objects use {Object#deep_copy +:deep_copy+} instead.
18
16
  #
19
17
  def save(method=:dup)
20
18
  return if self == @@undoable_history[self.object_id] # nichts zu tun
@@ -22,23 +20,21 @@ module Undoable
22
20
  end
23
21
 
24
22
 
25
- # Rückgriff auf den gespeicherten Zustand eines Objektes.
26
- # Der gespeicherte Zustand verbleibt im Speicher.
23
+ # Loads a saved state of an object, the saved state remains in memory.
27
24
  #
28
25
  def load_and_keep
29
26
  @@undoable_history[self.object_id]
30
27
  end
31
28
 
32
29
 
33
- # Rückgriff auf den gespeicherten Zustand eines Objektes.
34
- # Der gespeicherte Zustand wird verworfen.
30
+ # Loads a saved state of an object, the saved state will be discarded.
35
31
  #
36
32
  def load_and_delete
37
33
  @@undoable_history.delete(self.object_id)
38
34
  end
39
35
 
40
36
 
41
- # Verwirft alle gepeicherten Objektzustände.
37
+ # Discards all saved states of all objects.
42
38
  #
43
39
  def self.clear
44
40
  @@undoable_history.clear
data/lib/kyanite/hash.rb CHANGED
@@ -1,4 +1,10 @@
1
1
  # ruby encoding: utf-8
2
+ # ü
3
+ if $0 == __FILE__
4
+ require 'drumherum'
5
+ smart_init
6
+ end
7
+
2
8
  require 'active_support/core_ext/hash/slice' # Slice a hash to include only the given keys.
3
9
  require 'active_support/core_ext/hash/reverse_merge' # Merges the caller into +other_hash+.
4
10
  require 'kyanite/enumerable' # is_collection?
@@ -11,72 +17,56 @@ require 'kyanite/enumerable' # is_collection?
11
17
 
12
18
 
13
19
 
14
- # [ | Kyanite | Object | Array | Set | Enumerable | *Hash* | ] | *Hash* | Dictionary |
15
- # ---
16
- #
17
- #
18
- # == *Tools* *For* *Hash*
19
- # See TestKyaniteHash for tests and examples.
20
- #
21
- # === Generelle Anmerkungen zu Hashes
22
- # Definiert man in irgendeinem Objekt die Methode <tt>==(other)</tt>, so muss man auch die Methode +hash+ neu definieren!
23
- #
24
- # Rubys +delete+ und +delete_if+ verändern den Hash! Siehe TestHash#test_delete
25
- #
26
- #
27
- class Hash
28
20
 
29
21
 
30
- if RUBY_VERSION < "1.9"
31
-
32
- # Credit: Paul Murur http://mucur.name/posts/when-is-a-set-not-a-set
33
- # Create a hash based on the keys and values.
34
- def hash
35
- keys.hash + values.hash + (default ? default.hash : 0)
36
- end
37
-
38
- # Credit: Paul Murur http://mucur.name/posts/when-is-a-set-not-a-set
39
- # To determine whether two hashes are the same, compare their hashes.
40
- def eql?(other)
41
- hash == other.hash
42
- end
43
-
44
- end # Ruby Version
22
+ # @!macro hash
23
+ class Hash
45
24
 
46
25
 
47
-
48
- # Entfernt alle Key-Value-Paare mit <b>nil-Keys</b> in-place.
49
- # Tests: TestHash#test_delete
26
+ # Deletes all key-value pairs with <b>nil-keys</b> in-place.
27
+ # @return [Hash] in-place modificated
50
28
  def compact_keys!
51
29
  delete_if {|key, value| key.nil? }
52
30
  end
53
31
 
54
32
 
55
- # Entfernt alle alle Key-Value-Paare mit <b>nil-Values</b> in-place.
56
- # Tests: TestHash#test_compact
33
+ # Deletes all key-value pairs with <b>nil-values</b> in-place.
34
+ # @return [Hash] in-place modificated
57
35
  def compact_values!
58
36
  delete_if {|key, value| value.nil? }
59
37
  end
60
38
 
61
39
 
62
- # Entfernt das Key-Value-Paar mit einem bestimmten Key in-place.
63
- # Rückgabe ist der modifizierte Hash (im Gegensatz zur +delete+-Methode, die das entfernte Key-Value-Paar zurückgibt! ).
40
+ # Deletes the key-value pair with a <b>given key</b> in-place.
41
+ # Returns the modificated hash (in contrast to Rubys +delete+ method that returns the deleted key-value pair! ).
42
+ # @return [Hash] in-place modificated
64
43
  def delete_key(key)
65
44
  delete_if { |k,v| k == key }
66
45
  end
67
46
 
68
- # Entfernt alle Key-Value-Paare mit einem bestimmten Value in-place.
69
- #
47
+ # Deletes all key-value pairs with a <b>given value</b> in-place.
48
+ # Returns the modificated hash (in contrast to Rubys +delete+ method that returns the deleted key-value pair! ).
49
+ # @return [Hash] in-place modificated
70
50
  def delete_value(value)
71
51
  delete_if { |k,v| v == value }
72
52
  end
73
53
 
74
-
75
- # erzwingt ein Array der Länge 1, wenn sowohl Einzelwerte als auch Arrays erlaubt sind.
76
- # Beispiel:
77
- # inputoptions = options.arrayize(:skip, :debug)
54
+
55
+ # Forces some options in a methods options hash to be an array.
56
+ # Useful if both individual values ​​and arrays are allowed as an input option.
57
+ #
58
+ # Example:
59
+ # options = { :skip => 1, :debug => true, :test => false }
60
+ # puts options
61
+ # => {:skip=>1, :debug=>true, :test=>false}
62
+ #
63
+ # options.arrayize!(:skip, :debug)
64
+ # puts options
65
+ # => {:skip=>[1], :debug=>[true], :test=>false}
78
66
  #
79
- def arrayize(*keys)
67
+ # @return [Hash]
68
+ # @param keys [Key, Array of keys] Keys to process
69
+ def arrayize!(*keys)
80
70
  keys.each do |k|
81
71
  if self[k] && !self[k].respond_to?(:first)
82
72
  self[k] = [self[k]]
@@ -87,7 +77,7 @@ class Hash
87
77
  end
88
78
 
89
79
 
90
- # Greift auf den Hash mit nicht-ganz-passenden Schlüsseln zu
80
+ # Accesses the hash with keys that do not match exactly
91
81
  #
92
82
  def fuzzyget(key, level = 3)
93
83
  try = self[key]
@@ -99,12 +89,9 @@ class Hash
99
89
  end
100
90
 
101
91
 
102
- # Liefert die Verteilung der size
103
- # oder die Verteilung der class
104
- # oder die Verteilung eines anderen Merkmals der aufgezählten Elemente.
105
- # Siehe auch Enumerable#distribution.
106
- # Die Keys des Hash werden ignoriert.
107
- #
92
+ # Returns the distribution of +size+, +class+ or any other characteristic of the enumerated elements.
93
+ # The keys of the hash will be ignored. See also {Enumerable#distribution}, examples there.
94
+ # @return [Array]
108
95
  def distribution( mode = :size)
109
96
  verteilung = Hash.new
110
97
  each do | key, element |
@@ -119,8 +106,8 @@ class Hash
119
106
  end
120
107
 
121
108
 
122
- # liefert irgendein Value
123
- #
109
+
110
+ # @return any value
124
111
  def first
125
112
  self.each do |key, value|
126
113
  return value
@@ -128,8 +115,7 @@ class Hash
128
115
  end #def
129
116
 
130
117
 
131
- # liefert irgendein anderes Value
132
- #
118
+ # @return any other value
133
119
  def last
134
120
  first = nil
135
121
  self.each do |key, value|
@@ -143,7 +129,21 @@ class Hash
143
129
  end #def
144
130
 
145
131
 
146
-
132
+ # if RUBY_VERSION < "1.9"
133
+
134
+ # Credit: Paul Murur http://mucur.name/posts/when-is-a-set-not-a-set
135
+ # Create a hash based on the keys and values.
136
+ # def hash
137
+ # keys.hash + values.hash + (default ? default.hash : 0)
138
+ # end
139
+
140
+ # Credit: Paul Murur http://mucur.name/posts/when-is-a-set-not-a-set
141
+ # To determine whether two hashes are the same, compare their hashes.
142
+ # def eql?(other)
143
+ # hash == other.hash
144
+ # end
145
+
146
+ # end # Ruby Version
147
147
 
148
148
 
149
149
  end #class
@@ -167,9 +167,14 @@ end
167
167
  #
168
168
  if $0 == __FILE__
169
169
 
170
- test = {:b => 2, :a => 1, :c => 3}
171
- see test.first
172
- see test.last
170
+ require 'perception'
171
+
172
+ options = { :skip => 1, :debug => true, :test => false }
173
+ puts options
174
+ options.arrayize!(:skip)
175
+ puts options
176
+
177
+
173
178
 
174
179
 
175
180