italian-ruby 1.5.3 → 1.5.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
  SHA256:
3
- metadata.gz: 842d190a74cdee51fa6df713f0333ea77d720fcf306e33f80a0b679d7c5c5368
4
- data.tar.gz: 88faa3868b041267798f4150138aea7923c66ae8248d5d9380e66c37fc08c5c3
3
+ metadata.gz: c1550fed9fa5d8627a12423a83717323320906d71af217af9971b1dc17d0ad4d
4
+ data.tar.gz: 985f523686345ec7362b1e06181276da70c6d1fba9f026b36d11d9d8fd23d4b4
5
5
  SHA512:
6
- metadata.gz: 811fc9e4d55c2d9d386b79a026d81051d3e328c477b8a433d79eedd2266250e1346fe871fdfce96ffaa512bc2eb472e601f52c1d59f4c57512e710fab316a7cb
7
- data.tar.gz: 8b2279c79e6c2f573a4334949bdc2345b0725d575c81deab0eb08fb4f6ea07d203efa35e9711c067ede8790de6f9f7741c69bdee1bbdfcfe2c6779807efac947
6
+ metadata.gz: 76f69ca7661e93da77319403fe443fe8d9abee62a797bc09bee70db8f474c317a418f4228639f2598e353ccab32d363a3f86c5d5d2ce3b1e44f2b365520b098e
7
+ data.tar.gz: 4b35ab2ba0a2abd0be8b784f2000e4652e6ddf598705cb38c4d5531fc349f7dd034ad6e1c34464605be7e8245a75f08a50b72ad9ab2e51d30814f97751eb6054
@@ -14,6 +14,41 @@ class Array
14
14
  !include? *args
15
15
  end
16
16
 
17
+ ##
18
+ # Divide la lista in 100 pacchetti in modo che ogni pacchetto abbia
19
+ # lo stesso numero di elementi.
20
+ def in_pacchetti_percentuali
21
+ conteggio = self.count
22
+
23
+ if conteggio < 100
24
+ avanzamento = 100.0 / conteggio
25
+ indice = 0
26
+
27
+ self.each.with_index do |elemento, indice_elemento|
28
+ pacchetto = [ elemento ]
29
+ indice += avanzamento
30
+ indice = 100 if indice_elemento == conteggio - 1
31
+ yield pacchetto, indice.round, 100 if block_given?
32
+ end
33
+ else
34
+ avanzamento = conteggio / 100.0
35
+ elementi_presi = 0
36
+ percentile = 0
37
+ indice = 0
38
+
39
+ while percentile < 100
40
+ elementi_da_prendere = (indice + avanzamento).round - 1
41
+ pacchetto = self[elementi_presi..elementi_da_prendere]
42
+ elementi_presi = elementi_da_prendere + 1
43
+ indice += avanzamento
44
+ percentile += 1
45
+ yield pacchetto, percentile, 100 if block_given?
46
+ end
47
+ end
48
+
49
+ self
50
+ end
51
+
17
52
  ##
18
53
  # Esegue i metodi specificati per ogni elemento della lista.
19
54
  def campiona(*method_names)
@@ -1,5 +1,5 @@
1
1
  module Italian
2
2
  module Ruby
3
- VERSIONE = "1.5.3"
3
+ VERSIONE = "1.5.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: italian-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.3
4
+ version: 1.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francesco Ballardin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-20 00:00:00.000000000 Z
11
+ date: 2021-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler