string_plus 0.5.1 → 0.5.2

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: b8b7c74c711f2986bd1cb0d1d3f16b4b01ab8734
4
- data.tar.gz: cbec14d3e709e570bff0785b382cbbdff7fc50c2
3
+ metadata.gz: 33d40d790b1ff9aea27718c7fdc4cb3c0fa7a71a
4
+ data.tar.gz: 3e0959e1393dd73ccdeae353acc6ed3f359fb4bf
5
5
  SHA512:
6
- metadata.gz: f4fac4616326236cfbf21a37fa62cf09bf975dae08031c1685fcbefca920047b438619e379d5f0e2bfa82ea86fec892b91ddeceab6aa372d0167747550605ee9
7
- data.tar.gz: d5de369c329ac9d58079f261f6528d542bddcc3941774d73e8b0b38a4f9252cdacfa1a00ec6e3693b8eb01492cea2bc1df94fb5ef6a6563b91e9736bfc9db838
6
+ metadata.gz: 01afba878f61b8d169e6ead7c644a40b8301ca9c50287156d7ab0d1a1b71116c773bbb29cb71ca1307ad71a980f3cf13ecc550b5f5d8841a404f64341f40a82d
7
+ data.tar.gz: c781f36c8c5b6509ddb54202beb9a0eb6e8ad83e48335b444c6f1bfa74993b02a9681665f1dc984f72f5875b575675c27413a1ed295b39d976bc8c9092779fae
data/lib/string_plus.rb CHANGED
@@ -2,10 +2,10 @@ require "string_plus/version"
2
2
 
3
3
  module StringPlus
4
4
  module_function
5
- def camelcase(capitalize_first_char=true)
5
+ def camelcase(str=self, capitalize_first_char=true)
6
6
  res = ""
7
7
  flag = capitalize_first_char
8
- self.each_char {|w|
8
+ str.each_char {|w|
9
9
  (flag = true ; next) if w == "_" || w == " "
10
10
  res << if flag
11
11
  flag = false
@@ -17,14 +17,14 @@ module StringPlus
17
17
  res
18
18
  end
19
19
 
20
- def lcamelcase
20
+ def lcamelcase(str=self)
21
21
  camelcase(false)
22
22
  end
23
23
 
24
- def underscore
25
- return self.downcase if self.each_char.all? { |c| c == c.upcase && c =~ /[a-zA-Z0-9]/}
24
+ def underscore(str=self)
25
+ return str.downcase if str.each_char.all? { |c| c == c.upcase && c =~ /[a-zA-Z0-9]/}
26
26
  res = ""
27
- [nil, *self.each_char].each_cons(2) do |last, current|
27
+ [nil, *str.each_char].each_cons(2) do |last, current|
28
28
  res << "_" if last !=nil && current == current.upcase && !("0".."9").include?(current)
29
29
  res << current.downcase unless current == " "
30
30
  end
@@ -32,8 +32,8 @@ module StringPlus
32
32
  end
33
33
  alias :snakecase :underscore
34
34
 
35
- def constantize
36
- c = self.split("-").map(&:camelcase).join("::")
35
+ def constantize(str=self)
36
+ c = str.split("-").map(&:camelcase).join("::")
37
37
  Object.send(:const_get, c)
38
38
  end
39
39
  end
@@ -1,3 +1,3 @@
1
1
  module StringPlus
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: string_plus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Federico Iachetti