typ 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/typ.rb +27 -6
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e38d74e0f2bb298612cbc9c76ce190d53537d1a204d00821f7d28a3afcc9ab6
4
- data.tar.gz: 17d1212f324b8da8f7170d19e94f144f308d1dca53bf5b6697a68d742b79b52c
3
+ metadata.gz: b0f29f7c51d7e758efd8a0d5aa3ff2df8c3bd67f090eb85d7aa9f8e0d8856bd3
4
+ data.tar.gz: 31233ba93d6e965dd3cbcbb9aac0d887d43c826b9fb859282906e40167642c2f
5
5
  SHA512:
6
- metadata.gz: a96d036cc19728923e36e888663f6ba35ed18c1e168180f52344024be92c4d6f66a6480c8037fa7cfc644e166e10f6128f2973286eb88746681683b582489a11
7
- data.tar.gz: fae6fb96a7f0ce79a5ceec290c597f1801e20647c438fcf5fbd3a06a252126cd17b5eae51008a3c4db0e1a76995a8f24699d2f525419b061194748e68b784052
6
+ metadata.gz: e8e04787c558ca19a07774e8e8e5d1b16e89af45f5a9e82a72fdafbcdd2dfc69efead9215b4c29610df33949b4873f8c7258c9aa9fe584c613185951377cdfd5
7
+ data.tar.gz: f50128054edf6eedd8974e5bd704416ada9e48dd3f4bf006d1c5b549ce5a5806bf5ee998ffb3e41dd24a57a5d79158efa1f965164902a3bcb96c19b72a2cf863
data/lib/typ.rb CHANGED
@@ -23,7 +23,7 @@ module Typ
23
23
  def is type
24
24
  case type
25
25
  when Array
26
- gates << Is::Array[type]
26
+ gates << Is::Array.new(type)
27
27
  when Class
28
28
  if type.include? Typ
29
29
  gates << type
@@ -36,8 +36,12 @@ module Typ
36
36
  end
37
37
  end
38
38
 
39
- class Is
40
- class << self
39
+ module Is
40
+ def self.included gate
41
+ gate.extend Singleton
42
+ end
43
+
44
+ module Singleton
41
45
  attr_accessor :check
42
46
  end
43
47
 
@@ -49,9 +53,9 @@ module Typ
49
53
  @ok
50
54
  end
51
55
 
52
- class Array < self
56
+ module Array
53
57
  class << self
54
- def [] array
58
+ def new array
55
59
  check = if array[0].is_a?(Symbol)
56
60
  method, *arguments = array
57
61
  -> receiver { receiver.send method, *arguments }
@@ -62,11 +66,28 @@ module Typ
62
66
  fail "not sure how to handle #{array} yet"
63
67
  end
64
68
 
65
- gate = Class.new self
69
+ gate = Class.new
70
+
71
+ gate.include Is
66
72
  gate.check = check
73
+
74
+ gate.include self
75
+ gate.array = array
67
76
  gate
68
77
  end
69
78
  end
79
+
80
+ def self.included gate
81
+ gate.extend Singleton
82
+ end
83
+
84
+ module Singleton
85
+ attr_accessor :array
86
+ end
87
+
88
+ def to_a
89
+ self.class.array
90
+ end
70
91
  end
71
92
  end
72
93
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typ
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anatoly Chernow