aromat 0.2.2 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +20 -0
- data/lib/aromat.rb +1 -0
- data/lib/aromat/pad.rb +28 -0
- data/lib/aromat/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 115b2f3aaa3b7473584c8ad57e7a4d863c3969e3
|
4
|
+
data.tar.gz: df0eab1520ff9dbfefea4591c42fbd4819548c16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 860e9b6ddc2656312b65cbacccb97a2010307cab257d4a26aad41be059d410660e666413bfac5d43f09bc284cf4a8987dcc5ebe753f974f6b303a77da873a7ec
|
7
|
+
data.tar.gz: cd40905628ef68af314f29d7caf27f32f94f5c0fd7420af4b85f7c3522449f38a2736b9cfa8b3a56f1f2f4ba0194a1023f636b5b1bd404f5c38f587271e48aac
|
data/README.md
CHANGED
@@ -49,6 +49,26 @@ b
|
|
49
49
|
# => {:foo=>"bar", :nested=>[{:problems=>"none"}]}
|
50
50
|
```
|
51
51
|
|
52
|
+
### Padding
|
53
|
+
|
54
|
+
Two padding methods _rpad_ and _lpad_ are monkey-patched into the *String* class, and provide a way to pad any string to a given length using a given filler string.
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
a = 'foo'
|
58
|
+
a.rpad 10
|
59
|
+
# => "foo "
|
60
|
+
a.rpad 10, '-'
|
61
|
+
# => "foo-------"
|
62
|
+
a.rpad 2, '-'
|
63
|
+
# => "fo"
|
64
|
+
a.lpad 10
|
65
|
+
# => " foo"
|
66
|
+
a.lpad 10, '-'
|
67
|
+
# => "-------foo"
|
68
|
+
a.rpad 2, '-'
|
69
|
+
# => "oo"
|
70
|
+
```
|
71
|
+
|
52
72
|
## License
|
53
73
|
|
54
74
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/lib/aromat.rb
CHANGED
data/lib/aromat/pad.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# Aromat
|
2
|
+
# by Eresse <eresse@eresse.net>
|
3
|
+
|
4
|
+
# Monkey-patch String Class
|
5
|
+
class String
|
6
|
+
|
7
|
+
# Right-Pad
|
8
|
+
# Right-Pads a String to a given length using a given filler
|
9
|
+
# @param [Fixnum] size
|
10
|
+
# @param [String] fill
|
11
|
+
# @return [String] A copy of the original String, padded to [size] with [fill]
|
12
|
+
def rpad size, fill = ' '
|
13
|
+
s = clone
|
14
|
+
s = "#{s}#{fill}" while s.size < size
|
15
|
+
s.slice 0, size
|
16
|
+
end
|
17
|
+
|
18
|
+
# Left-Pad
|
19
|
+
# Left-Pads a String to a given length using a given filler
|
20
|
+
# @param [Fixnum] size
|
21
|
+
# @param [String] fill
|
22
|
+
# @return [String] A copy of the original String, padded to [size] with [fill]
|
23
|
+
def lpad size, fill = ' '
|
24
|
+
s = clone
|
25
|
+
s = "#{fill}#{s}" while s.size < size
|
26
|
+
s.slice s.size - size, size
|
27
|
+
end
|
28
|
+
end
|
data/lib/aromat/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aromat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eresse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- aromat.gemspec
|
68
68
|
- lib/aromat.rb
|
69
69
|
- lib/aromat/dclone.rb
|
70
|
+
- lib/aromat/pad.rb
|
70
71
|
- lib/aromat/sym_keys.rb
|
71
72
|
- lib/aromat/version.rb
|
72
73
|
homepage: http://redmine.eresse.net/projects/aromat
|
@@ -89,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
90
|
version: '0'
|
90
91
|
requirements: []
|
91
92
|
rubyforge_project:
|
92
|
-
rubygems_version: 2.
|
93
|
+
rubygems_version: 2.5.1
|
93
94
|
signing_key:
|
94
95
|
specification_version: 4
|
95
96
|
summary: Small extensions to Ruby core libraries to make your life easier
|