rubyplb 0.2.9 → 0.2.91

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.
@@ -0,0 +1,14 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rubyplb (0.2.9)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+
10
+ PLATFORMS
11
+ ruby
12
+
13
+ DEPENDENCIES
14
+ rubyplb!
@@ -2,6 +2,7 @@
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
4
  $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
5
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib/rubyplb')
5
6
  require 'trollop'
6
7
  require 'rubyplb'
7
8
  require 'ruby_graphviz'
@@ -9,9 +9,9 @@
9
9
  require 'ruby_graphviz'
10
10
 
11
11
  ## load ary_with_combination if not Ruby 1.9.x
12
- # unless Array.instance_methods.index(:combination)
13
- # require 'ary_with_combination'
14
- # end
12
+ unless Array.instance_methods.index(:combination)
13
+ require 'ary_with_combination'
14
+ end
15
15
 
16
16
  def showerror(sentence, severity)
17
17
  if severity == 0
@@ -0,0 +1,33 @@
1
+ class Array
2
+ @@combi_indices_hash = {}
3
+
4
+ def combi_indices(s,n)
5
+ ret = @@combi_indices_hash[s] ||= []
6
+ if ret.empty?
7
+ s.times{|i|
8
+ ret.dup.each{|a|
9
+ ret.push(a+[i])
10
+ }
11
+ ret.push([i])
12
+ }
13
+ end
14
+ ret.select{|a|a.size==n}
15
+ end
16
+
17
+ def combination(n)
18
+ # combination of Ruby 1.9.x returns array with a blank array as its top
19
+ combi_indices(self.size,n).collect{|a| self.values_at(*a)}.unshift([])
20
+ end
21
+
22
+ def subsets
23
+ (0..length).inject([]) do |ret, n|
24
+ ret.push(*combination(n))
25
+ end.uniq
26
+ end
27
+
28
+ def true_subsets
29
+ (1..length).inject([]) do |ret, n|
30
+ ret.push(*combination(n))
31
+ end.uniq
32
+ end
33
+ end
@@ -1,3 +1,3 @@
1
1
  module Rubyplb
2
- VERSION = "0.2.9"
2
+ VERSION = "0.2.91"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyplb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.2.91
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-12-13 00:00:00.000000000 Z
13
+ date: 2012-12-15 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: Command line Pattern Lattice building tool written in Ruby.
16
16
  email:
@@ -23,6 +23,7 @@ files:
23
23
  - .document
24
24
  - .gitignore
25
25
  - Gemfile
26
+ - Gemfile.lock
26
27
  - LICENSE
27
28
  - README.md
28
29
  - Rakefile
@@ -30,6 +31,7 @@ files:
30
31
  - bin/rubyplb
31
32
  - lib/ruby_graphviz.rb
32
33
  - lib/rubyplb.rb
34
+ - lib/rubyplb/ary_with_combination.rb
33
35
  - lib/rubyplb/version.rb
34
36
  - lib/trollop.rb
35
37
  - rubyplb.gemspec