rbnf 0.0.0 → 0.0.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.
- data/lib/rbnf/matcher.rb +4 -4
- data/lib/rbnf/version.rb +1 -1
- data/test/case/repetition.rb +18 -0
- metadata +3 -1
data/lib/rbnf/matcher.rb
CHANGED
|
@@ -27,11 +27,11 @@ module RBNF
|
|
|
27
27
|
if n == 0
|
|
28
28
|
Matcher.new {|s| s.empty? }
|
|
29
29
|
elsif n == 1
|
|
30
|
-
|
|
30
|
+
rep
|
|
31
31
|
elsif Integer===n and n>1
|
|
32
32
|
Matcher.new do |s|
|
|
33
|
-
|
|
34
|
-
end
|
|
33
|
+
(2..n).inject(self) {|m| m.cat self}[s]
|
|
34
|
+
end.rep
|
|
35
35
|
else
|
|
36
36
|
raise ArgumentError, "can't repeat #{self} #{n} times"
|
|
37
37
|
end
|
|
@@ -40,7 +40,7 @@ module RBNF
|
|
|
40
40
|
private
|
|
41
41
|
|
|
42
42
|
def parts(s)
|
|
43
|
-
(0..s.size-1).map {|i| s[0..i]}.select {|h| self[h]}
|
|
43
|
+
(0..s.size-1).map {|i| s[0..i]}.push('').select {|h| self[h]}
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
def comps(s)
|
data/lib/rbnf/version.rb
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'rbnf'
|
|
2
|
+
class Repetition
|
|
3
|
+
def binary_repetition
|
|
4
|
+
RBNF[?A]*3+?G
|
|
5
|
+
end
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
Graham.pp(Repetition) do |that|
|
|
9
|
+
that.binary_repetition.is_such_that {
|
|
10
|
+
self =~ 'G' and
|
|
11
|
+
self =~ 'AAAG' and
|
|
12
|
+
self =~ 'AAAAAAG'
|
|
13
|
+
}.and_such_that {
|
|
14
|
+
not self =~ '' and
|
|
15
|
+
not self =~ 'AG' and
|
|
16
|
+
not self =~ 'AAG'
|
|
17
|
+
}
|
|
18
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rbnf
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.1
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -39,6 +39,7 @@ files:
|
|
|
39
39
|
- lib/rbnf/matcher.rb
|
|
40
40
|
- Rakefile
|
|
41
41
|
- test/case/defs.rb
|
|
42
|
+
- test/case/repetition.rb
|
|
42
43
|
homepage: http://github.com/gwentacle/ebnf
|
|
43
44
|
licenses: []
|
|
44
45
|
post_install_message:
|
|
@@ -66,3 +67,4 @@ summary: Extended Backus-Naur Form implementation for Ruby
|
|
|
66
67
|
test_files:
|
|
67
68
|
- Rakefile
|
|
68
69
|
- test/case/defs.rb
|
|
70
|
+
- test/case/repetition.rb
|