typ 0.0.3 → 0.0.4
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/lib/typ.rb +41 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fd8dec5f85b936ddd6ac783c195ef36a64e9b9772e4e0ad88f83b9f378bed98
|
4
|
+
data.tar.gz: 7eebc316790fbd446cbe1c8cc4336f1009e2c8a3dbb2cb8d5c99f174028b387a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2ff2a040ed1d280905ee65f991a2919709733a9d030236285535be6d4a75a53ebfa93d0cea6b3fda5b2a521de490eb09570b622e4a6bd6b79b93787f8729c29
|
7
|
+
data.tar.gz: 31cb152e6959b1ec8ed078ca118f50e667bc4a1519fb2b0068504cbd48666dbfadb63971f37c6c99396e870228b3c07c4e44b8b3144a25c9722ede6fc6e693ac
|
data/lib/typ.rb
CHANGED
@@ -34,6 +34,15 @@ module Typ
|
|
34
34
|
fail "don't know how to create a Gate from #{type}"
|
35
35
|
end
|
36
36
|
end
|
37
|
+
|
38
|
+
def is_a type
|
39
|
+
case type
|
40
|
+
when Module
|
41
|
+
gates << IsA.new(type)
|
42
|
+
else
|
43
|
+
fail "don't know how to create a Gate from #{type}"
|
44
|
+
end
|
45
|
+
end
|
37
46
|
end
|
38
47
|
|
39
48
|
module Is
|
@@ -79,4 +88,36 @@ module Typ
|
|
79
88
|
end
|
80
89
|
end
|
81
90
|
end
|
91
|
+
|
92
|
+
module IsA
|
93
|
+
class << self
|
94
|
+
def new type
|
95
|
+
check = -> it { it.is_a? type }
|
96
|
+
|
97
|
+
gate = Class.new
|
98
|
+
gate.include self
|
99
|
+
gate.check = check
|
100
|
+
gate
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def self.included gate
|
105
|
+
gate.extend Singleton
|
106
|
+
end
|
107
|
+
|
108
|
+
module Singleton
|
109
|
+
attr_accessor :check
|
110
|
+
end
|
111
|
+
|
112
|
+
def ok?
|
113
|
+
@ok
|
114
|
+
end
|
115
|
+
|
116
|
+
def initialize it
|
117
|
+
@it = it
|
118
|
+
@ok = self.class.check[it]
|
119
|
+
end
|
120
|
+
|
121
|
+
attr_reader :it
|
122
|
+
end
|
82
123
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: typ
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anatoly Chernow
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|