sliced_bread 0.0.1 → 0.0.2

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.
Files changed (3) hide show
  1. data/lib/sliced_bread.rb +28 -0
  2. metadata +11 -9
  3. checksums.yaml +0 -7
@@ -14,4 +14,32 @@ Array.class_eval do
14
14
  self[size-number.to_i...size]
15
15
  end
16
16
  end
17
+
18
+ def middle(count)
19
+ array_count = self.count
20
+ selection_indices = Array.new
21
+
22
+ if array_count.even?
23
+ # even array
24
+ selection_indices.push(array_count/2-1, array_count/2)
25
+ else
26
+ # odd array
27
+ selection_indices.push(array_count/2)
28
+ end
29
+ count_adjust = count - selection_indices.count
30
+ left_buffer = count_adjust % 2
31
+ left_limit = selection_indices.first - left_buffer - count_adjust/2
32
+ right_limit = selection_indices.last + count_adjust/2
33
+
34
+ case count
35
+ when count < selection_indices.count
36
+ self[left_limit]
37
+ else
38
+ self[left_limit..right_limit]
39
+ end
40
+ end
41
+
42
+ def delete_if_contains(substring)
43
+ self.delete_if{|el| el.match(substring)}
44
+ end
17
45
  end
metadata CHANGED
@@ -1,18 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sliced_bread
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Amit Suryavanshi, Yashasree Barve, Souranil Sen, Twinkal Savani, Priya Joshi
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-02-17 00:00:00.000000000 Z
12
+ date: 2014-02-18 00:00:00.000000000 Z
12
13
  dependencies: []
13
14
  description: A simple array slicer gem
14
- email: 'amit.s@gmail.com, yashasree.barve@gmail.com, souranil.sen@gmail.com, twinkal.savani@gmail.com,
15
- priya.joshi@gmail.com '
15
+ email: ! 'amitbsuryavanshi@gmail.com, yashasree.barve@gmail.com, souranil.sen@gmail.com,
16
+ twinkal.savani@gmail.com, priya.joshi@gmail.com '
16
17
  executables: []
17
18
  extensions: []
18
19
  extra_rdoc_files: []
@@ -21,25 +22,26 @@ files:
21
22
  homepage: http://rubygems.org/gems/sliced_bread
22
23
  licenses:
23
24
  - MIT
24
- metadata: {}
25
25
  post_install_message:
26
26
  rdoc_options: []
27
27
  require_paths:
28
28
  - lib
29
29
  required_ruby_version: !ruby/object:Gem::Requirement
30
+ none: false
30
31
  requirements:
31
- - - '>='
32
+ - - ! '>='
32
33
  - !ruby/object:Gem::Version
33
34
  version: '0'
34
35
  required_rubygems_version: !ruby/object:Gem::Requirement
36
+ none: false
35
37
  requirements:
36
- - - '>='
38
+ - - ! '>='
37
39
  - !ruby/object:Gem::Version
38
40
  version: '0'
39
41
  requirements: []
40
42
  rubyforge_project:
41
- rubygems_version: 2.0.6
43
+ rubygems_version: 1.8.25
42
44
  signing_key:
43
- specification_version: 4
45
+ specification_version: 3
44
46
  summary: A simple array slicer gem
45
47
  test_files: []
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 6f6695f560a3a17a71f5472f9fb5bdff6af446b0
4
- data.tar.gz: 6fdc09f828eb71ef3168e21661f6911bb5835951
5
- SHA512:
6
- metadata.gz: f15627f630edbd5e350caa40278b609e3a27487430b26899ca968a1ca989959fa73ea725477c19b0071dcf1836c087df050dd38427ecd13d9cb9eac36eb9c3eb
7
- data.tar.gz: d50334eb1a1333cc213b0b1282d32269361f965e51cc1cdc95417a1f77963c2ae0df686b8729077b9814f6c86879c5d7b647c918c5dc6c40bb9e8b6f3800d604