kdict 0.1.1 → 0.1.2
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.
- checksums.yaml +4 -4
- data/README.md +3 -6
- data/lib/kdict/kwargdict/kwargtypes.rb +2 -2
- data/lib/kdict/kwargdict.rb +1 -1
- data/lib/kdict/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '08f77aac21c890e2fd0acaeddd38c3f87126f99865893c8188da67501c1093e7'
|
|
4
|
+
data.tar.gz: 6fda813fd3f05f78a27e73a506860644975d0a31c181e91b19a9986a79690556
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 79ca787e4671e909b4d3e2bcbab30f5f7032033d4f31d1b22be6fe0c463701aac721c93c1a4de00e307bf17c9f226dfdd07004db9b0a667996e2d0cea509e552
|
|
7
|
+
data.tar.gz: 493a2f0f6daeb48be8b038c399dca41ad987d583381d518c54145c9ff08383259e333656692788ea5481e9b6e20dfd0014d93613f048c48318652bd4ed0a447e
|
data/README.md
CHANGED
|
@@ -16,9 +16,6 @@ View source code at: https://github.com/stkterry/KDict/
|
|
|
16
16
|
|
|
17
17
|
{file:doc/Example1.md}
|
|
18
18
|
|
|
19
|
-
*Note: I'm very new to Ruby, less than a month in, as it were. I suspect this thing might change quite a bit
|
|
20
|
-
as I better familiarize myself with everything.*
|
|
21
|
-
|
|
22
19
|
***
|
|
23
20
|
|
|
24
21
|
### KwargDict
|
|
@@ -38,7 +35,7 @@ allowed to modify a label, it's fontsize, it's color, and x_data for a graph.
|
|
|
38
35
|
```ruby
|
|
39
36
|
kdict[:label] = :typeof, String
|
|
40
37
|
kdict[:fontsize] = :typeof, Integer
|
|
41
|
-
kdict[:rgb] = :formof, [Integer]*3, Proc.new { |n|
|
|
38
|
+
kdict[:rgb] = :formof, [Integer]*3, Proc.new { |n| 0 <= n && n <= 255 }
|
|
42
39
|
kdict[:x_data] = :arrayof, Float
|
|
43
40
|
|
|
44
41
|
# Or if you prefer a single command
|
|
@@ -193,7 +190,7 @@ my_dict.check(:example, [false, 3.1, "Holly Dolly"]) # => true
|
|
|
193
190
|
my_dict.check(:example, [false, 3.1]) # => false
|
|
194
191
|
my_dict.check(:example, ["Holly Dolly", 3.1, false]) # => false
|
|
195
192
|
|
|
196
|
-
my_dict[:proc_example] = :formof, [Integer, Float, Float], Proc.new { |n|
|
|
193
|
+
my_dict[:proc_example] = :formof, [Integer, Float, Float], Proc.new { |n| 1 < n && n < 3 }
|
|
197
194
|
my_dict.check(:proc_example, [2, 1.1, 1.2]) # => true
|
|
198
195
|
my_dict.check(:proc_example, [1.1, 2, 1.4]) # => false
|
|
199
196
|
```
|
|
@@ -237,7 +234,7 @@ my_dict.check(:example, [3.1, [1, 2, 3, 4, 5]]) # => true
|
|
|
237
234
|
my_dict.check(:example, [3.1, ['1', '2', '3']]) # => false
|
|
238
235
|
|
|
239
236
|
my_dict[:proc_example] = :adv_formof, [[:typeof, String, Proc.new { |s| s.length > 5 }],
|
|
240
|
-
[:formof, [Float]*3 , Proc.new { |n| n
|
|
237
|
+
[:formof, [Float]*3 , Proc.new { |n| 0 <= n && n <= 1 }]]
|
|
241
238
|
my_dict.check(:proc_example, ["Longer", [0.25, 0.5, 1.0]]) # => true
|
|
242
239
|
my_dict.check(:proc_example, ["Longer", [-0.25, 0.5, -1.0]]) # => false
|
|
243
240
|
my_dict.check(:proc_example, ["Short", [0.25, 0.5, 1.0]]) # => false
|
|
@@ -95,7 +95,7 @@ module KwargTypes
|
|
|
95
95
|
# * Can accept a Proc that must return true for ALL values in the array.
|
|
96
96
|
# @example (Called From a KwargDict instance)
|
|
97
97
|
# my_dict[:example] = :formof, [Bool, Float, String]
|
|
98
|
-
# my_dict[:proc_example] = :formof, [Integer, Float, Float], Proc.new { |n|
|
|
98
|
+
# my_dict[:proc_example] = :formof, [Integer, Float, Float], Proc.new { |n| 1 < n && n < 3 }
|
|
99
99
|
# my_dict.check(:example, [false, 3.1, "Holly Dolly"]) # => true
|
|
100
100
|
# my_dict.check(:example, [false, 3.1]) # => false
|
|
101
101
|
# my_dict.check(:example, ["Holly Dolly", 3.1, false]) # => false
|
|
@@ -137,7 +137,7 @@ module KwargTypes
|
|
|
137
137
|
# @example (Called From a KwargDict instance)
|
|
138
138
|
# my_dict[:example] = :adv_formof, [[:typeof, Float], [:arrayof, Integer]]
|
|
139
139
|
# my_dict[:proc_example] = :adv_formof, [[:typeof, String, Proc.new { |s| s.length > 5 }],
|
|
140
|
-
# [:formof, [Float]*3 , Proc.new { |n| n
|
|
140
|
+
# [:formof, [Float]*3 , Proc.new { |n| 0 <= n && n <= 1 }]]
|
|
141
141
|
# my_dict.check(:example, [3.1, [1, 2, 3, 4, 5]]) # => true
|
|
142
142
|
# my_dict.check(:example, [3.1, ['1', '2', '3']]) # => false
|
|
143
143
|
# my_dict.check(:proc_example, ["Longer", [0.25, 0.5, 1.0]]) # => true
|
data/lib/kdict/kwargdict.rb
CHANGED
|
@@ -56,7 +56,7 @@ class KwargDict < Hash
|
|
|
56
56
|
# @return [Boolean]
|
|
57
57
|
# @example Adding a KwargModel and Checking User Input Against It:
|
|
58
58
|
# my_dict[:label] = :typeof, String
|
|
59
|
-
# my_dict[:rgba] = :formof, [Numeric]*4, Proc.new { |n|
|
|
59
|
+
# my_dict[:rgba] = :formof, [Numeric]*4, Proc.new { |n| 0 <= n && n <= 1 }
|
|
60
60
|
# my_dict.check(:label, 'Labels Are Fun!') #=> true
|
|
61
61
|
# my_dict.check(:label, 45) #=> false
|
|
62
62
|
# my_dict.check(:rgba, [0.5, 1, 0.25, 1]) #=> true
|
data/lib/kdict/version.rb
CHANGED