typ 0.0.3 → 0.0.4

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 +41 -0
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e49bb76b04240c1b96f1b20b1eb5cc2fce4168ee0b730e3b768ff3787b3d8e98
4
- data.tar.gz: c4425deabbbb4fa53346ceb33b0697cc88b5b7094114f8549f9ea5fd222363e2
3
+ metadata.gz: 8fd8dec5f85b936ddd6ac783c195ef36a64e9b9772e4e0ad88f83b9f378bed98
4
+ data.tar.gz: 7eebc316790fbd446cbe1c8cc4336f1009e2c8a3dbb2cb8d5c99f174028b387a
5
5
  SHA512:
6
- metadata.gz: e6cea78fa037f0d53208139274c39871da6431c338c20399f9af93928ab12812397963b602e2fd05d4999edc0295b431239243798ba09684f3547dfcf0a7bc67
7
- data.tar.gz: d1c39f5d629a4b9b0a90e3aebc23f8c1bea7d713670463d0d5acd1a0a52a1e00997306da275c4a8ff623e02b9c1baa41d037fab63287063ff4d4b8f28b125da4
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.3
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-26 00:00:00.000000000 Z
11
+ date: 2018-04-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: