circuits 0.11.0 → 0.11.1
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 +8 -8
- data/lib/circuits/component/base.rb +11 -16
- data/lib/circuits/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZDQ3YmZhMTQxMjJmODRhZDQ1MDA0MWU2ZTc3NTIxNTljY2E3MzA2OQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NzJhYTU4NjRhNjhmMWFmOWJjZjM5MTg5YzhkZmFhYzY4ODYyZjdhNQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NDkxODk0MmRlZTk1MjdlMGRmODAzMWExZDNjMDllNWVjYWVkMTM3NTcyZjFh
|
10
|
+
ZWQwYmI2MzQ5ZjZkMTZjMGZkMWE4ZTdlM2Y5NjJhZmI2N2I1ZWZhMWZmYWZk
|
11
|
+
MTY4M2E2NDE3YTYxNmRjZjQ0NzVjZWVmM2NkMWMxYWY1NTMxNjk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
N2VmZWMyZWQ5NzViMjUxNGNlNThiY2I0MzlhYzc5NjE0ZGUyOThkYjlhMmY1
|
14
|
+
YzExOWQxZTlmNDg5MDZkYjc0YjMxYzcwNDRlNWQ5ZjA3MzZlNzg2ZjQyNzJl
|
15
|
+
NTI4OGViNDMzNzA2OTA3NzcxZDNjMTM1MzFjM2Q0Njg0YzJjNzY=
|
@@ -21,6 +21,7 @@ module Circuits
|
|
21
21
|
@port_mappings = create_port_mappings opts
|
22
22
|
@sub_components = opts[:sub_components] || []
|
23
23
|
@ticks = opts[:ticks] || 0
|
24
|
+
declare_ports_as_methods
|
24
25
|
end
|
25
26
|
|
26
27
|
# the inputs of this component
|
@@ -29,15 +30,6 @@ module Circuits
|
|
29
30
|
# the outputs of this component
|
30
31
|
attr_reader :outputs
|
31
32
|
|
32
|
-
# For easy access to the ports
|
33
|
-
# @param [Symbol] method_name The name of the method
|
34
|
-
# @return [Input, Outpus] The corresponding port
|
35
|
-
def method_missing(method_name, *_, &__)
|
36
|
-
res = self[method_name]
|
37
|
-
super if res.nil?
|
38
|
-
res
|
39
|
-
end
|
40
|
-
|
41
33
|
# Computes the outputs based on the inputs and previous state
|
42
34
|
def tick
|
43
35
|
@ticks.times.each do
|
@@ -51,13 +43,6 @@ module Circuits
|
|
51
43
|
outputs.each(&:tock)
|
52
44
|
end
|
53
45
|
|
54
|
-
# So we can advertise what ports are available from {#method_missing}
|
55
|
-
# @param [Symbol] method_name The name of the method
|
56
|
-
# @return [Boolean] Wether or a method call will be responded to
|
57
|
-
def respond_to_missing?(method_name, _)
|
58
|
-
!self[method_name].nil? || super
|
59
|
-
end
|
60
|
-
|
61
46
|
# Gets the teminal assigned to the port
|
62
47
|
# @param port [Symbol] The symbol that represents the terminal
|
63
48
|
# @return [Input, Output] The terminal
|
@@ -94,6 +79,16 @@ module Circuits
|
|
94
79
|
res
|
95
80
|
end
|
96
81
|
|
82
|
+
def declare_ports_as_methods
|
83
|
+
@port_mappings.each do |method, _|
|
84
|
+
(class << self; self; end).class_eval do
|
85
|
+
define_method method do
|
86
|
+
self[method]
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
97
92
|
def input_mappings(input_names)
|
98
93
|
return default_input_mappings unless input_names.class == Array
|
99
94
|
input_names.map.each_with_index do |input_name, num|
|
data/lib/circuits/version.rb
CHANGED