aromat 0.4.0 → 0.5.0

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: d4adde93bac853bdb099f7b61a0fedcd2b0dff2a
4
- data.tar.gz: 2883765e20e05f48d5a8248b0b4b00c57655182e
3
+ metadata.gz: 9a05b3f2d5d2f433784d344e6688c8f81eaec0f0
4
+ data.tar.gz: af6c4b10177aa51619d6baf148d3acec7c456fb2
5
5
  SHA512:
6
- metadata.gz: 13ce7f8dc73e26dde039b680019f1f399b0ffc195a29974e7b49fc25184d4580734d0f3dfcd85239d993a94ceb33636635d739045a5834b336f9bec1e66cc694
7
- data.tar.gz: 8818b99d8eb1cd553b09518adef7653f9e4c40ffa00d8f28bd1ded96a39d2d2778c8e5b16b7ab0321ac20c986554ffc1a65271b61b5dcce947a928a79ca915f8
6
+ metadata.gz: a71047aa1b2f9d68f67b01a0987e2f7485cd434f1e79cc84e58f6e579bf0fe061fa6e4c65d89b5ecf9ee0ad03d12f4cd7d3299eb20777138ec17141cd98c32d2
7
+ data.tar.gz: 717e14bf9518ed297b1954320e9488b6c9b2d0ef66fe2a5a05e5032bb565b8ed47e83607bc6d152cb46624d5e57f85be48449873ae126825fc1191e1ced80900
data/README.md CHANGED
@@ -49,7 +49,7 @@ b
49
49
  # => {:foo=>"bar", :nested=>[{:problems=>"none"}]}
50
50
  ```
51
51
 
52
- ### Padding
52
+ ### Right/Left Padding
53
53
 
54
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
55
 
@@ -69,7 +69,7 @@ a.rpad 2, '-'
69
69
  # => "oo"
70
70
  ```
71
71
 
72
- ### Try
72
+ ### Object Try (Undefined Method Call)
73
73
 
74
74
  A _try_ method is monkey-patched into the *Object* root class, providing a means to call undefined methods on objects without raising anything (returning *nil* instead).
75
75
 
@@ -82,6 +82,21 @@ A _try_ method is monkey-patched into the *Object* root class, providing a means
82
82
  # => 35
83
83
  ```
84
84
 
85
+ ### Get Non-Empty String
86
+
87
+ A _nstr_ method is monkey-patched into the *String* class. This method returns nil when the String is empty, the String otherwise.
88
+
89
+ ```ruby
90
+ ''.nstr
91
+ # => nil
92
+ 'foo'.nstr
93
+ # => 'foo'
94
+ nil.try :nstr
95
+ # => nil
96
+ 'bar'.try :nstr
97
+ # => 'bar'
98
+ ```
99
+
85
100
  ## License
86
101
 
87
102
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,12 @@
1
+ # Aromat
2
+ # by Eresse <eresse@eresse.net>
3
+
4
+ # Monkey-patch String Class
5
+ class String
6
+
7
+ # Non-Empty String
8
+ # @return [String] The string if non-empty, nil otherwise
9
+ def nstr
10
+ self == '' ? nil : self
11
+ end
12
+ end
@@ -5,5 +5,5 @@
5
5
  module Aromat
6
6
 
7
7
  # Version
8
- VERSION = '0.4.0'
8
+ VERSION = '0.5.0'
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aromat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eresse
@@ -67,6 +67,7 @@ files:
67
67
  - aromat.gemspec
68
68
  - lib/aromat.rb
69
69
  - lib/aromat/dclone.rb
70
+ - lib/aromat/nstr.rb
70
71
  - lib/aromat/pad.rb
71
72
  - lib/aromat/sym_keys.rb
72
73
  - lib/aromat/try.rb