left-pad 1.0.0 → 1.1.0

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. checksums.yaml +4 -4
  2. data/lib/left-pad.rb +3 -18
  3. metadata +9 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc4e6922e9961c8ac6eb70b0db4990c9e7061726
4
- data.tar.gz: 5d12fb048dde49991220a5ae48e60f7be1d0f86a
3
+ metadata.gz: 90af475d12b03690f71f6e1665a54b9b0afb3948
4
+ data.tar.gz: f97ce98175ba2261b960d96e659330300189125e
5
5
  SHA512:
6
- metadata.gz: dea18e5d5f2c1e1857c91d5e6cf5a90a2f854324384b770f4f1b6661ff56e37b32f146010be2defdf63664c9e789089c2668fcf29a25e5174510601118489850
7
- data.tar.gz: 7959174afa0e4d2f43d7510b7d52278435cb9fcaa0579b500784322b3a29dfdbc496144f76035da76c0b4f2589685eca90c885abd92e7a7abe5cbe52514e00d1
6
+ metadata.gz: 837cc86e663346a31345f9258ad19df658fdae9ffa15e7c7e45f9bf91f7a46167a624972475eab207967b818f44213d8404f82c7e65f7a3de7904a2fb00aedd7
7
+ data.tar.gz: 3a6dc059c63af03e1549927453564f8c399e8805997f3e607b06fb5a2ce90775425c3b9635d47da69bfba0f65ddd9a0dff0935d558436416677c518b7a1c4599
@@ -1,23 +1,8 @@
1
- class InvalidCharError < StandardError; end
2
-
3
- class LeftPad
4
- def LeftPad.leftpad(string, length, character=' ')
5
- string = string.to_s
1
+ class String
2
+ def leftpad(length, character=' ')
6
3
  character = character.to_s
7
4
  length = length.to_i
8
5
 
9
- if character.length != 1
10
- raise InvalidCharError.new("Invalid character '#{character}'")
11
- end
12
-
13
- length = length - string.length
14
-
15
- if length > 0
16
- length.times do
17
- string = "#{character}#{string}"
18
- end
19
- end
20
-
21
- string
6
+ self.rjust(length, character)
22
7
  end
23
8
  end
metadata CHANGED
@@ -1,23 +1,24 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: left-pad
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Somsubhra Bairi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-23 00:00:00.000000000 Z
11
+ date: 2016-03-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Left pad a string with a character. Inspired by npm left-pad.
13
+ description: Left pad a string. Inspired by the famous npm left-pad which broke the
14
+ internet.
14
15
  email: mail@somsubhra.com
15
16
  executables: []
16
17
  extensions: []
17
18
  extra_rdoc_files: []
18
19
  files:
19
20
  - lib/left-pad.rb
20
- homepage: http://rubygems.org/gems/left-pad
21
+ homepage: https://github.com/Somsubhra/left-pad
21
22
  licenses:
22
23
  - MIT
23
24
  metadata: {}
@@ -27,18 +28,18 @@ require_paths:
27
28
  - lib
28
29
  required_ruby_version: !ruby/object:Gem::Requirement
29
30
  requirements:
30
- - - ">="
31
+ - - '>='
31
32
  - !ruby/object:Gem::Version
32
33
  version: '0'
33
34
  required_rubygems_version: !ruby/object:Gem::Requirement
34
35
  requirements:
35
- - - ">="
36
+ - - '>='
36
37
  - !ruby/object:Gem::Version
37
38
  version: '0'
38
39
  requirements: []
39
40
  rubyforge_project:
40
- rubygems_version: 2.5.1
41
+ rubygems_version: 2.0.14
41
42
  signing_key:
42
43
  specification_version: 4
43
- summary: Left pad a string with a character
44
+ summary: Left pad a string
44
45
  test_files: []