phrase_assembler 1.0.8 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -25,4 +25,18 @@ class PACompositeProxy < PAAutomateProxy
25
25
  end
26
26
  end
27
27
 
28
+ def method_missing(sym, *args, &block)
29
+ if args[0].is_a? Hash
30
+ options = args.delete_at(0)
31
+ end_proxy = super(sym, *args, &block)
32
+ if end_proxy.data.is_a? Array
33
+ return end_proxy.collect{|proxy| proxy.to_s(options)}
34
+ else
35
+ return end_proxy.to_s(options)
36
+ end
37
+ else
38
+ return super(sym, *args, &block)
39
+ end
40
+ end
41
+
28
42
  end
@@ -1,5 +1,6 @@
1
1
  require 'yaml'
2
2
  require 'hash_add_on'
3
+ require 'RArray'
3
4
  class PAProxyData
4
5
  attr_accessor :data
5
6
  attr_accessor :logger
@@ -23,6 +24,14 @@ class PAProxyData
23
24
  return self.class.new(p_data, self.logger)
24
25
  end
25
26
 
27
+ def collect
28
+ out_array = RArray.new
29
+ for i in 0...@data.length
30
+ out_array << yield(new_instance(@data[i]))
31
+ end
32
+ out_array
33
+ end
34
+
26
35
  def [](index)
27
36
  if @data.is_a? Array
28
37
  if index == :r
data/lib/RArray.rb ADDED
@@ -0,0 +1,9 @@
1
+ class RArray < Array
2
+ def [](index)
3
+ if index == :r
4
+ return super(rand(self.length))
5
+ else
6
+ return super(index)
7
+ end
8
+ end
9
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phrase_assembler
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 8
10
- version: 1.0.8
9
+ - 9
10
+ version: 1.0.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Lovro \xC5\xBDmak, Radan Skori\xC4\x87, Drap"
@@ -53,6 +53,7 @@ files:
53
53
  - lib/PAProxies/PAStringProxy.rb
54
54
  - lib/PAProxies/PATokenProxy.rb
55
55
  - lib/phrase_assembler.rb
56
+ - lib/RArray.rb
56
57
  has_rdoc: true
57
58
  homepage: http://www.drap.hr
58
59
  licenses: []