aromat 0.2.2 → 0.3.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fae5f776d79b1b207b3abb4e6056094530344b9a
4
- data.tar.gz: 4e43f8f425582191282fa9f126f37c4b9b7c11e2
3
+ metadata.gz: 115b2f3aaa3b7473584c8ad57e7a4d863c3969e3
4
+ data.tar.gz: df0eab1520ff9dbfefea4591c42fbd4819548c16
5
5
  SHA512:
6
- metadata.gz: b55fb8934dcda2cb2b72f42dd99121086093e776397c3599255ba500da3cb82c6499eccb1c7a05c2c9707f1d3448fb9a274c26c4ddf8bce8a1d06d6207e8364e
7
- data.tar.gz: 82885521ba533ade80c59609421a711b227c17c0dd0c55e3ca5d8f6de5593a3429454937e029a0857e8070bff19a4d3ba83210db4737d5d30b45ed91ac15981b
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).
@@ -5,6 +5,7 @@
5
5
  require 'aromat/version'
6
6
  require 'aromat/sym_keys'
7
7
  require 'aromat/dclone'
8
+ require 'aromat/pad'
8
9
 
9
10
  # Aromat Module
10
11
  # Root Module for Aromat
@@ -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
@@ -5,5 +5,5 @@
5
5
  module Aromat
6
6
 
7
7
  # Version
8
- VERSION = '0.2.2'
8
+ VERSION = '0.3.1'
9
9
  end
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.2.2
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-13 00:00:00.000000000 Z
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.6.10
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