oh_my_method 0.0.3 → 0.0.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
  SHA1:
3
- metadata.gz: de64df8090017c131c6c5b34a24a53a1942585f3
4
- data.tar.gz: 210b2aa51a39f20a0efe82fba868077356c2525e
3
+ metadata.gz: 905eeb3d2a3e0d615a7f017a20e413bebc300722
4
+ data.tar.gz: 09a6f2550bbcb436b173cfa9d6a622dbfd8b7a41
5
5
  SHA512:
6
- metadata.gz: e24904ff458fa1c90bc089c0f3180f15e6a1746649b7e77e32795637d0d18777ca950fe5ba0db9ebb9665f82b7096d6658f60e256a92eecd430e0b25af3e332a
7
- data.tar.gz: 3df4827b441824e282fd534a9b39a0f6926e3ef9b046930e6cf748d3da1e39deee98bf188f06ef461e0f508e4057fc8025eb8047e41e090eec09e71363caac66
6
+ metadata.gz: de6c5d1be80889e5e531748f6f280a12ef465d8f0621aab1209ae0b98dfc0f7bd77d3afbd6e10f64b3af72b1a21ec92140d38cab11268d24ed543ae4281d2a6c
7
+ data.tar.gz: 8003274bafa52dcbca25bb4992cc7b9d0c0f12451b0cd5cfe5d2030fbef11fb80d43da7a3e65a006d7ed92f22de509048463a4426c70eeb66ce4096910e6c310
@@ -2,4 +2,12 @@ class String
2
2
  def palindrome?
3
3
  self == self.reverse
4
4
  end
5
+
6
+ def middle_with?(str)
7
+ (self =~ /.+#{str}.+/)? true : false
8
+ end
9
+
10
+ def sum_digit
11
+ self.chars.map(&:to_i).inject(:+)
12
+ end
5
13
  end
@@ -1,3 +1,3 @@
1
1
  module OhMyMethod
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -7,4 +7,17 @@ describe "String Class" do
7
7
  expect("Heeeh".palindrome?).to eq false
8
8
  expect("ABCBA".palindrome?).to eq true
9
9
  end
10
+
11
+ it "middle_with?" do
12
+ expect("hello".middle_with?("ell")).to eq true
13
+ expect("hello".middle_with?("ello")).to eq false
14
+ expect("hello".middle_with?("hel")).to eq false
15
+ expect("ABABA".middle_with?("BAB")).to eq true
16
+ end
17
+
18
+ it "sum_digit" do
19
+ expect("11111".sum_digit).to eq 5
20
+ expect("12321".sum_digit).to eq 9
21
+ expect("123456789".sum_digit).to eq 45
22
+ end
10
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oh_my_method
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - siman-man
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-01 00:00:00.000000000 Z
11
+ date: 2014-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler