eymiha_util 0.1.6 → 1.0.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 (106) hide show
  1. data/gem_package.rb +3 -3
  2. data/html/classes/Eymiha.html +144 -0
  3. data/html/classes/{BaseEnvelope.html → Eymiha/BaseEnvelope.html} +21 -21
  4. data/html/classes/Eymiha/BaseEnvelope.src/M000010.html +18 -0
  5. data/html/classes/Eymiha/BaseEnvelope.src/M000011.html +20 -0
  6. data/html/classes/Eymiha/BaseEnvelope.src/M000012.html +18 -0
  7. data/html/classes/{Enum.html → Eymiha/Enum.html} +5 -27
  8. data/html/classes/{Envelope.html → Eymiha/Envelope.html} +52 -52
  9. data/html/classes/Eymiha/Envelope.src/M000025.html +19 -0
  10. data/html/classes/Eymiha/Envelope.src/M000026.html +19 -0
  11. data/html/classes/Eymiha/Envelope.src/M000027.html +35 -0
  12. data/html/classes/Eymiha/Envelope.src/M000028.html +19 -0
  13. data/html/classes/Eymiha/Envelope.src/M000029.html +19 -0
  14. data/html/classes/Eymiha/Envelope.src/M000030.html +26 -0
  15. data/html/classes/Eymiha/Envelope.src/M000032.html +18 -0
  16. data/html/classes/{EnvelopeException.html → Eymiha/EnvelopeException.html} +5 -5
  17. data/html/classes/{ForwardReference.html → Eymiha/ForwardReference.html} +16 -16
  18. data/html/classes/Eymiha/ForwardReference.src/M000033.html +21 -0
  19. data/html/classes/Eymiha/ForwardReference.src/M000034.html +18 -0
  20. data/html/classes/{ForwardReferencer.html → Eymiha/ForwardReferencer.html} +12 -5
  21. data/html/classes/{ForwardReferencing.html → Eymiha/ForwardReferencing.html} +51 -51
  22. data/html/classes/Eymiha/ForwardReferencing.src/M000001.html +20 -0
  23. data/html/classes/Eymiha/ForwardReferencing.src/M000002.html +20 -0
  24. data/html/classes/Eymiha/ForwardReferencing.src/M000003.html +20 -0
  25. data/html/classes/Eymiha/ForwardReferencing.src/M000004.html +32 -0
  26. data/html/classes/Eymiha/ForwardReferencing.src/M000005.html +18 -0
  27. data/html/classes/Eymiha/ForwardReferencing.src/M000006.html +25 -0
  28. data/html/classes/Eymiha/ForwardReferencing.src/M000007.html +18 -0
  29. data/html/classes/Eymiha/ForwardReferencing.src/M000008.html +18 -0
  30. data/html/classes/Eymiha/ForwardReferencing.src/M000009.html +18 -0
  31. data/html/classes/{Histogram.html → Eymiha/Histogram.html} +65 -65
  32. data/html/classes/Eymiha/Histogram.src/M000016.html +19 -0
  33. data/html/classes/Eymiha/Histogram.src/M000017.html +21 -0
  34. data/html/classes/Eymiha/Histogram.src/M000018.html +37 -0
  35. data/html/classes/Eymiha/Histogram.src/M000019.html +18 -0
  36. data/html/classes/{Histogram.src/M000015.html → Eymiha/Histogram.src/M000020.html} +5 -9
  37. data/html/classes/Eymiha/Histogram.src/M000021.html +20 -0
  38. data/html/classes/Eymiha/Histogram.src/M000022.html +20 -0
  39. data/html/classes/Eymiha/Histogram.src/M000023.html +20 -0
  40. data/html/classes/Eymiha/Histogram.src/M000024.html +24 -0
  41. data/html/classes/{HistogramException.html → Eymiha/HistogramException.html} +5 -5
  42. data/html/classes/{MethodicHash.html → Eymiha/MethodicHash.html} +22 -22
  43. data/html/classes/Eymiha/MethodicHash.src/M000013.html +22 -0
  44. data/html/classes/Eymiha/MethodicHash.src/M000014.html +23 -0
  45. data/html/classes/Eymiha/MethodicHash.src/M000015.html +23 -0
  46. data/html/created.rid +1 -1
  47. data/html/files/lib/{enum_rb.html → eymiha/util/enum_rb.html} +3 -3
  48. data/html/files/lib/{envelope_rb.html → eymiha/util/envelope_rb.html} +3 -3
  49. data/html/files/lib/{forward_referencing_rb.html → eymiha/util/forward_referencing_rb.html} +6 -8
  50. data/html/files/lib/{histogram_rb.html → eymiha/util/histogram_rb.html} +3 -3
  51. data/html/files/lib/eymiha/util/methodic_hash_rb.html +101 -0
  52. data/html/files/lib/eymiha/util_rb.html +112 -0
  53. data/html/fr_class_index.html +11 -10
  54. data/html/fr_file_index.html +6 -5
  55. data/html/fr_method_index.html +34 -34
  56. data/html/index.html +1 -1
  57. data/lib/eymiha/util.rb +5 -0
  58. data/lib/eymiha/util/enum.rb +59 -0
  59. data/lib/eymiha/util/envelope.rb +130 -0
  60. data/lib/eymiha/util/forward_referencing.rb +161 -0
  61. data/lib/eymiha/util/histogram.rb +112 -0
  62. data/lib/eymiha/util/methodic_hash.rb +70 -0
  63. data/test/tc_enum.rb +1 -1
  64. data/test/tc_envelope.rb +4 -2
  65. data/test/tc_forward_referencing.rb +3 -1
  66. data/test/tc_histogram.rb +3 -1
  67. data/test/tc_methodic_hash.rb +4 -1
  68. metadata +70 -62
  69. data/html/classes/BaseEnvelope.src/M000001.html +0 -18
  70. data/html/classes/BaseEnvelope.src/M000002.html +0 -20
  71. data/html/classes/BaseEnvelope.src/M000003.html +0 -18
  72. data/html/classes/Envelope.src/M000016.html +0 -19
  73. data/html/classes/Envelope.src/M000017.html +0 -19
  74. data/html/classes/Envelope.src/M000018.html +0 -35
  75. data/html/classes/Envelope.src/M000019.html +0 -19
  76. data/html/classes/Envelope.src/M000020.html +0 -19
  77. data/html/classes/Envelope.src/M000021.html +0 -26
  78. data/html/classes/Envelope.src/M000023.html +0 -18
  79. data/html/classes/ForwardReference.src/M000024.html +0 -21
  80. data/html/classes/ForwardReference.src/M000025.html +0 -18
  81. data/html/classes/ForwardReferencing.src/M000026.html +0 -20
  82. data/html/classes/ForwardReferencing.src/M000027.html +0 -20
  83. data/html/classes/ForwardReferencing.src/M000028.html +0 -20
  84. data/html/classes/ForwardReferencing.src/M000029.html +0 -32
  85. data/html/classes/ForwardReferencing.src/M000030.html +0 -18
  86. data/html/classes/ForwardReferencing.src/M000031.html +0 -25
  87. data/html/classes/ForwardReferencing.src/M000032.html +0 -18
  88. data/html/classes/ForwardReferencing.src/M000033.html +0 -18
  89. data/html/classes/ForwardReferencing.src/M000034.html +0 -18
  90. data/html/classes/Histogram.src/M000007.html +0 -19
  91. data/html/classes/Histogram.src/M000008.html +0 -21
  92. data/html/classes/Histogram.src/M000009.html +0 -37
  93. data/html/classes/Histogram.src/M000010.html +0 -18
  94. data/html/classes/Histogram.src/M000011.html +0 -20
  95. data/html/classes/Histogram.src/M000012.html +0 -20
  96. data/html/classes/Histogram.src/M000013.html +0 -20
  97. data/html/classes/Histogram.src/M000014.html +0 -20
  98. data/html/classes/MethodicHash.src/M000004.html +0 -22
  99. data/html/classes/MethodicHash.src/M000005.html +0 -23
  100. data/html/classes/MethodicHash.src/M000006.html +0 -23
  101. data/html/files/lib/methodic_hash_rb.html +0 -140
  102. data/lib/enum.rb +0 -57
  103. data/lib/envelope.rb +0 -126
  104. data/lib/forward_referencing.rb +0 -157
  105. data/lib/histogram.rb +0 -109
  106. data/lib/methodic_hash.rb +0 -66
data/lib/histogram.rb DELETED
@@ -1,109 +0,0 @@
1
- # Histograms have lots of uses - whenever you need to keep track of the
2
- # occurences of items and how many times they've occured, a histogram is
3
- # just what's needed.
4
-
5
-
6
- # An exception thrown when adding Arrays to Histograms that cannot be
7
- # meaningfully interpretted.
8
- class HistogramException < Exception
9
- end
10
-
11
-
12
- # A Histogram is a hash whose values are counts of the occurences of the keys.
13
- class Histogram < Hash
14
-
15
- # Creates and returns an instance. If arguments are given, they are passed to
16
- # the add method to initialize the new instance.
17
- def initialize(key=nil,number=1)
18
- super()
19
- add(key,number) unless key == nil
20
- end
21
-
22
- # Returns the number of occurences of the given key. If an array of keys
23
- # is given, the sum of the number of occurences of those keys is returned.
24
- def count(check_keys = keys)
25
- check_keys = [check_keys] if ! check_keys.kind_of? Array
26
- count = 0
27
- check_keys.each { |key| count += self[key] if has_key? key }
28
- count
29
- end
30
-
31
- # Adds the key to the instance if it doesn't already exist, and adds the
32
- # specified count to it value. If the key is
33
- # * an Array, each member of the array is added. if the member itself is an Array, then if that array has one member, the member is added as a key; if two members, the member is added as a key and a count; otherwise, a HistogramException is thrown.
34
- # * another histogram, the keys and counts in the key are added to the instance.
35
- def add(key,count=1)
36
- if key.kind_of? Array
37
- key.each { |member|
38
- if member.kind_of? Array
39
- if member.size == 1
40
- add(member[0])
41
- elsif (member.size == 2) && (member[1].kind_of? Fixnum)
42
- add(member[0],member[1])
43
- else
44
- raise HistogramException, "add cannot interpret Array to add"
45
- end
46
- else
47
- add member
48
- end
49
- }
50
- elsif key.kind_of? Histogram
51
- key.each_pair { |k,v| add(k,v) }
52
- else
53
- self[key] = ((value = self[key]) == nil) ? count : value+count
54
- end
55
- self
56
- end
57
-
58
- # Returns the number of keys in the instance.
59
- def key_count
60
- keys.size
61
- end
62
-
63
- # Returns a new Histogram containing the elements with occurences greater
64
- # than or equal to the given count.
65
- def >=(count)
66
- result = Histogram.new
67
- each_pair { |k,v| result.add(k,v) if v >= count }
68
- result
69
- end
70
-
71
- # Returns a new Histogram containing the elements with occurences greater
72
- # than the given count.
73
- def >(count)
74
- result = Histogram.new
75
- each_pair { |k,v| result.add(k,v) if v > count }
76
- result
77
- end
78
-
79
- # Returns a new Histogram containing the elements with occurences less than
80
- # or equal to the given count.
81
- def <=(count)
82
- result = Histogram.new
83
- each_pair { |k,v| result.add(k,v) if v <= count }
84
- result
85
- end
86
-
87
- # Returns a new Histogram containing the elements with occurences less than
88
- # the given count.
89
- def <(count)
90
- result = Histogram.new
91
- each_pair { |k,v| result.add(k,v) if v < count }
92
- result
93
- end
94
-
95
- # If count is a number, a new Histogram containing the elements with
96
- # occurences equal to the given countis returned. If the count is a
97
- # histogram, true is returned if the instance contains the same keys and
98
- # values; false otherwise.
99
- def ==(count)
100
- if count.kind_of? Numeric
101
- result = Histogram.new
102
- each_pair { |k,v| result.add(k,v) if v >= count }
103
- result
104
- else
105
- super
106
- end
107
- end
108
-
109
- end
data/lib/methodic_hash.rb DELETED
@@ -1,66 +0,0 @@
1
- # The MethodicHash is some method_missing magic that uses method names as hash
2
- # keys, so hash assignment and lookup appear to be attribute writing and
3
- # reading. For instance, if
4
- #
5
- # mh = MethodicHash.new
6
- # mh['four'] = 'iv'
7
- # mh[:seven] = 'vii'
8
- # mh.eighteen = 'xviii'
9
- #
10
- # then
11
- #
12
- # mh['four'] ---> 'iv'
13
- # mh[:four] ---> 'iv'
14
- # mh.four ---> 'iv'
15
- # mh['seven'] ---> 'vii'
16
- # mh[:seven] ---> 'vii'
17
- # mh.seven ---> 'vii'
18
- # mh['eighteen'] ---> 'xviii'
19
- # mh[:eighteen] ---> 'xviii'
20
- # mh.eighteen ---> 'xviii'
21
- #
22
- # This allows access to simply declared facts to be embedded in Ruby code and
23
- # leverages the possibility of hashing procs.
24
- #
25
- # Note that if the hash uses anything but strings or symbols as keys, the
26
- # magic stands a good chance of failing, raising an error or acting in a
27
- # bizarre manner. Note also that methods of the Hash cannot be used as
28
- # 'attribute' names.
29
- class MethodicHash < Hash
30
-
31
- # Try to look up using a key directly, or if that fails as a string, or as
32
- # a symbol as last resort. If a symbol conversion doesn't exists, rescue
33
- # with a nil.
34
- def [](key)
35
- begin
36
- super(key) || super(key.to_s) || super(key.to_sym)
37
- rescue
38
- nil
39
- end
40
- end
41
-
42
- # Deletes and returns the key-value pairs from hash whose keys are equal to
43
- # key.to_s or key.to_sym. If both key.to_s and key.to_sym are in the hash,
44
- # then both values are returned in an Array, respectively. If neither key is
45
- # found, the delete is deferred to the Hash.
46
- def delete(key,&block)
47
- values = [key.to_s, key.to_sym].collect {|k| super(k){ nil } }.compact
48
- case values.size
49
- when 0 then super(key,&block)
50
- when 1 then values[0]
51
- when 2 then values
52
- end
53
- end
54
-
55
- # A missing method is assummed to be the assignment of a value of a key, or
56
- # the lookup of a value with a key.
57
- def method_missing(method,*args)
58
- string = method.to_s
59
- if string[string.length-1,1] == '='
60
- self[string[0,string.length-1].to_sym] = args[0]
61
- else
62
- self[method]
63
- end
64
- end
65
-
66
- end