left-pad-rb 0.0.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.
- checksums.yaml +7 -0
- data/lib/left_pad.rb +11 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ba84bbb84f9b9ae484a9a044e06c81c003171a51
|
4
|
+
data.tar.gz: 780cd796b7b6feeb61b62a6a56df2ae816bc5517
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0a4cdc5ac08cb85f7212c19b7d4e35f8edaa5d660b47d663f177782d261d10ef107821e31a371365cb82c310c9030f47bfba8ccad4ac513ae96ecbbc9c9009cb
|
7
|
+
data.tar.gz: 5c33a9e0dea90194ccbb429afae3693d68d4dc2bae941f6bc38c75fe8f85b07886278a1e63735406f964d3d649ab4baa45b972c8f6d7e2326ce545e584e1afa4
|
data/lib/left_pad.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
module LeftPad
|
2
|
+
def self.left_pad(string, length, pad_with='.')
|
3
|
+
raise TypeError.new("String expected, received #{string.class}") unless string.is_a? String
|
4
|
+
raise TypeError.new("Fixnum expected, received #{string.class}") unless length.is_a? Fixnum
|
5
|
+
raise TypeError.new("String expected, received #{string.class}") unless pad_with.is_a? String
|
6
|
+
raise ArgumentError.new("Non-negative Fixnum expected, received #{length} ") unless length > -1
|
7
|
+
raise ArgumentError.new("String must be a single character.") unless pad_with.length === 1
|
8
|
+
|
9
|
+
string.prepend pad_with.to_s * length
|
10
|
+
end
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: left-pad-rb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris Escue
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-25 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Because micropackages are hip!
|
14
|
+
email: chris@escue.io
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/left_pad.rb
|
20
|
+
homepage: https://github.com/cescue/left-pad
|
21
|
+
licenses:
|
22
|
+
- WTFPL
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.4.5
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: A gem to left-pad a string with a given character.
|
44
|
+
test_files: []
|