logic_tools 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a2329d237d7038309287c2907d60d5a383760642
4
- data.tar.gz: d24b42399dcc9f835856e7ede9a539414f703dc1
3
+ metadata.gz: 901ddc00175b7abf309f63f45e246752e350d467
4
+ data.tar.gz: 6989af12e0185e71e8bad6922aebc6eb7cf17412
5
5
  SHA512:
6
- metadata.gz: 34433d985130bf65444113bc969347925f65d427b8400613f1daa0a2598a62158467abcd87c9c4fc67143faf2698dc5dbdb7c35d385222e906ec8ceeb0780c0b
7
- data.tar.gz: ac8e94c8d5ebd78c7cffa01c14dbd7fa626cd88a4af95be1a2cfebcbd26fa9ff3a8b058fb940495a177ed845b8348d72e5c474e00252a4581c5a56bf6600595c
6
+ metadata.gz: a618bc881cb959c8fef9311414ed4b969aafd67592f25eb3f21620f0da2d0eb5d909702b313391dc5c3af054049addc1add4cf3c8bd3d533994039ad7d0b0952
7
+ data.tar.gz: 9b1de33709d8088ef53347d578b4898aac18324a68494471852303fe45629c93a6741437fcf2ef89ac98872eec4f775b8a866dfe6ae34f812d69d1310c56aae5
@@ -72,6 +72,7 @@ module LogicTools
72
72
  ##
73
73
  # Represents a node of a tree representing a logical expression.
74
74
  class Node
75
+
75
76
  include Enumerable
76
77
 
77
78
  ## Gets a array containing the variables of the tree sorted by name.
@@ -100,9 +101,11 @@ module LogicTools
100
101
  # Iteration parameters (for the current line of the truth table):
101
102
  # * +vars+: the variables of the expression
102
103
  # * +val+: the value of the expression
103
- # --
104
- # TODO generate an Enumerator.
105
104
  def each_line
105
+ # No block given? Return an enumerator.
106
+ return to_enum(:each_line) unless block_given?
107
+
108
+ # Block given? Apply it.
106
109
  # Get the variables
107
110
  vars = self.getVariables
108
111
  # Compute the number of iterations
@@ -123,9 +126,11 @@ module LogicTools
123
126
  #
124
127
  # Iteration parameters:
125
128
  # * +vars+: the variables of the expression
126
- # --
127
- # TODO generate an Enumerator.
128
129
  def each_minterm
130
+ # No block given? Return an enumerator.
131
+ return to_enum(:each_minterm) unless block_given?
132
+
133
+ # Block given? Apply it.
129
134
  each_line { |vars,val| yield(vars) if val }
130
135
  end
131
136
 
@@ -133,9 +138,11 @@ module LogicTools
133
138
  #
134
139
  # Iteration parameters:
135
140
  # * +vars+: the variables of the expression
136
- # --
137
- # TODO generate an Enumerator.
138
141
  def each_maxterm
142
+ # No block given? Return an enumerator.
143
+ return to_enum(:each_maxterm) unless block_given?
144
+
145
+ # Block given? Apply it.
139
146
  each_line do |vars,val|
140
147
  unless val then
141
148
  vars.each { |var| var.value = !var.value }
@@ -145,10 +152,10 @@ module LogicTools
145
152
  end
146
153
 
147
154
  ## Iterate over the children.
148
- #
149
- # --
150
- # TODO generate an Enumerator.
151
155
  def each
156
+ # No block given? Return an enumerator.
157
+ return to_enum(:each) unless block_given?
158
+ # Block given? No child, so nothing to do anyway...
152
159
  end
153
160
 
154
161
  ## Generates the equivalent standard conjunctive form.
@@ -360,7 +367,6 @@ module LogicTools
360
367
  # Represents an operator node with multiple children.
361
368
  class NodeNary < Node
362
369
  extend Forwardable
363
- include Enumerable
364
370
 
365
371
  attr_reader :op
366
372
 
@@ -399,6 +405,10 @@ module LogicTools
399
405
 
400
406
  ## Iterates over the children.
401
407
  def each(&blk) # :nodoc:
408
+ # No block given? Return an enumerator.
409
+ return to_enum(:each) unless blk
410
+
411
+ # Block given? Apply it.
402
412
  @children.each(&blk)
403
413
  return self
404
414
  end
@@ -727,6 +737,10 @@ module LogicTools
727
737
 
728
738
  ## Iterates over the children.
729
739
  def each # :nodoc:
740
+ # No block given? Return an enumerator.
741
+ return to_enum(:each) unless block_given?
742
+
743
+ # Block given? Apply it.
730
744
  yield(@child)
731
745
  end
732
746
 
@@ -1,3 +1,3 @@
1
1
  module LogicTools
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
data/logic_tools.gemspec CHANGED
@@ -10,12 +10,12 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["lovic@ariake-nct.ac.jp"]
11
11
 
12
12
  spec.summary = %q{A set of tools for processing logic expressions.}
13
- spec.description = %Q{LogicTools is a set of command-line tools for processing logic expressions.
14
- The tools include:<p>
15
- * simplify_qm: for simplifying a logic expression.<p>
16
- * std_conj: for computing the conjunctive normal form of a logic expression.<p>
17
- * std_dij: for computing the disjunctive normal form a of logic expression.<p>
18
- * truth_tbl: for generating the truth table of a logic expression.}
13
+ spec.description = %Q{LogicTools is a set of command-line tools for processing logic expressions.
14
+ The tools include:
15
+ simplify_qm for simplifying a logic expression,
16
+ std_conj for computing the conjunctive normal form of a logic expression,
17
+ std_dij for computing the disjunctive normal form a of logic expression,
18
+ and truth_tbl for generating the truth table of a logic expression.}
19
19
  spec.homepage = "https://github.com/civol"
20
20
  spec.license = "MIT"
21
21
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logic_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lovic Gauthier
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-17 00:00:00.000000000 Z
11
+ date: 2016-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,13 +66,11 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- description: |-
70
- LogicTools is a set of command-line tools for processing logic expressions.
71
- The tools include:<p>
72
- * simplify_qm: for simplifying a logic expression.<p>
73
- * std_conj: for computing the conjunctive normal form of a logic expression.<p>
74
- * std_dij: for computing the disjunctive normal form a of logic expression.<p>
75
- * truth_tbl: for generating the truth table of a logic expression.
69
+ description: "LogicTools is a set of command-line tools for processing logic expressions.
70
+ \nThe tools include: \nsimplify_qm for simplifying a logic expression, \nstd_conj
71
+ for computing the conjunctive normal form of a logic expression, \nstd_dij for computing
72
+ the disjunctive normal form a of logic expression, \nand truth_tbl for generating
73
+ the truth table of a logic expression."
76
74
  email:
77
75
  - lovic@ariake-nct.ac.jp
78
76
  executables: