nobiru 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,646 @@
1
+ # Nobiru
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/nobiru.svg)](http://badge.fury.io/rb/nobiru)
4
+ [![Build Status](https://travis-ci.org/drexed/nobiru.svg?branch=master)](https://travis-ci.org/drexed/nobiru)
5
+ [![Coverage Status](https://coveralls.io/repos/drexed/nobiru/badge.png)](https://coveralls.io/r/drexed/nobiru)
6
+ [![Code Climate](https://codeclimate.com/github/drexed/nobiru.png)](https://codeclimate.com/github/drexed/nobiru)
7
+
8
+ Nobiru is a collection of commonly used object helpers in a ruby based project. It currently includes extensions for: arrays, enumerables, hashes, numerics, objects, strings, and time.
9
+
10
+ `Rails Safe` = methods extracted from rails but that do not override that rails method.
11
+
12
+ Highly recommended extensions:
13
+ * **Hash:** Hashie - https://github.com/intridea/hashie
14
+ * **String:** Escape Utils - https://github.com/brianmario/escape_utils
15
+ * **String:** Fast Blank - https://github.com/SamSaffron/fast_blank
16
+ * **Translation:** Fast Gettext - https://github.com/grosser/fast_gettext
17
+
18
+ ## Installation
19
+
20
+ Add this line to your application's Gemfile:
21
+
22
+ gem 'nobiru'
23
+
24
+ And then execute:
25
+
26
+ $ bundle
27
+
28
+ Or install it yourself as:
29
+
30
+ $ gem install nobiru
31
+
32
+ ## Usage
33
+
34
+ ### ArrayExtensions
35
+
36
+ ####Remove Blanks:####
37
+ Use the `remove_blanks` method removes blank elements from an array.
38
+
39
+ ```ruby
40
+ ["this", "", "that", nil].remove_blanks #=> ["this", "that"]
41
+ "this is a test".split(" ").remove_blanks #=> ["this", "is", "a", "test"]
42
+ ```
43
+
44
+ ####Remove First Element:####
45
+ Use the `remove_first` method removes the first element from an array. Like Array.shift, but returns the array instead of the removed element.
46
+
47
+ ```ruby
48
+ ["1", "2", "3"].remove_first #=> ["2", "3"]
49
+ ```
50
+
51
+ ####Remove Last Element:####
52
+ Use the `remove_last` method removes the last element from an array. Like Array.pop, but returns the array instead of the removed element.
53
+
54
+ ```ruby
55
+ ["1", "2", "3"].remove_last #=> ["1", "2"]
56
+ ```
57
+
58
+ ### EnumerableExtensions
59
+
60
+ ####Drop Last:####
61
+ Use the `drop_last` method to drops the last number of elements of a collection.
62
+
63
+ ```ruby
64
+ [1,2,3].drop_last(1) #=> [1,2]
65
+ [].drop_last(3) #=> []
66
+ ```
67
+
68
+ ####Drop Last While:####
69
+ Use the `drop_last_while` method to drops the last number of elements of a collection while it meets a criteria.
70
+
71
+ ```ruby
72
+ [1,2,3].drop_last_while(&:odd?) #=> [1,2]
73
+ [].drop_last_while(&:odd?) #=> []
74
+ ```
75
+
76
+ ####Exactly:####
77
+ Use the `exactly?` method to return if there are exactly the number of an element type.
78
+
79
+ ```ruby
80
+ [1,2,3].excatly?(3) #=> true
81
+ [1,1,3,3].exactly?(2, &:even?) #=> false
82
+ [].exactly?(1) #=> false
83
+ ```
84
+
85
+ ####Frequencies:####
86
+ Use the `frequencies` method to return a hash of the number of times a value in an array appears.
87
+
88
+ ```ruby
89
+ [1, :symbol, 'string', 3, :symbol, 1].frequencies #=> { 1 => 2, :symbol => 2, 'string' => 1, 3 => 1 }
90
+ [].frequencies #=> {}
91
+ ```
92
+ ####Max:####
93
+ Use the `max` method to return the largest value of a collection of numbers.
94
+
95
+ ```ruby
96
+ [2,3,1].max #=> 3
97
+ [].max #=> 0
98
+ [].max(nil) #=> nil
99
+ ```
100
+
101
+ ####Min:####
102
+ Use the `min` method to return the smallest value of a collection of numbers.
103
+
104
+ ```ruby
105
+ [2,3,1].min #=> 3
106
+ [].min #=> 0
107
+ [].min(nil) #=> nil
108
+ ```
109
+
110
+ ####Mean:####
111
+ Use the `mean` method to return the average of a collection of numbers.
112
+
113
+ ```ruby
114
+ [1,2,3].mean #=> 2
115
+ [].mean #=> 0
116
+ [].mean(nil) #=> nil
117
+ ```
118
+
119
+ ####Median:####
120
+ Use the `median` method to return the middle value of a collection of numbers.
121
+
122
+ ```ruby
123
+ [1,2,6].median #=> 2
124
+ [1,2,3,6].median #=> 2.5
125
+ [].median #=> 0
126
+ [].median(nil) #=> nil
127
+ ```
128
+
129
+ ####Mode:####
130
+ Use the `mode` method to return the most frequent value of a collection of numbers.
131
+
132
+ ```ruby
133
+ [1,1,2,46].mode #=> 1
134
+ [1,2,3].mode #=> nil
135
+ [].mode #=> 0
136
+ [].mode(nil) #=> nil
137
+ ```
138
+
139
+ ####Range:####
140
+ Use the `range` method to return the difference between the smallest and largest value of a collection of numbers.
141
+
142
+ ```ruby
143
+ [1,2,6].range #=> 5
144
+ [].range #=> 0
145
+ [].range(nil) #=> nil
146
+ ```
147
+
148
+ ####Several:####
149
+ Use the `several?` method to return if there are several types of an element.
150
+
151
+ ```ruby
152
+ [1,2,3].several? #=> true
153
+ [1,1,3,3].several?(&:even?) #=> false
154
+ [].several? #=> false
155
+ ```
156
+
157
+ ####Standard Deviation:####
158
+ Use the `standard_deviation` method to return the standard deviation of elements of a collection.
159
+
160
+ ```ruby
161
+ [1,2,6].standard_deviation #=> 2.6457513110645907
162
+ [].standard_deviation #=> nil
163
+ ```
164
+
165
+ ####Sum:####
166
+ Use the `sum` method to to return the sum of a collection of numbers.
167
+
168
+ ```ruby
169
+ [1,2,3].sum #=> 2
170
+ [1,2,3,4].sum #=> 2.5
171
+ [].sum #=> 0
172
+ [].sum(nil) #=> nil
173
+ ```
174
+
175
+ ####Take Last:####
176
+ Use the `take_last` method to return the last number of elements of a collection.
177
+
178
+ ```ruby
179
+ [1,2,3].take_last(2) #=> [2,3]
180
+ [].take_last(3) #=> []
181
+ ```
182
+
183
+ ####Take Last While:####
184
+ Use the `take_last_while` method to return the last number of elements of a collection while it meets a criteria.
185
+
186
+ ```ruby
187
+ [1,2,3,5].take_last_while(&:odd?) #=> [5, 5]
188
+ [].take_last_while(&:odd?) #=> []
189
+ ```
190
+
191
+ ####Variance:####
192
+ Use the `variance` method to return the variance of elements of a collection.
193
+
194
+ ```ruby
195
+ [1,2,6].variance #=> 7
196
+ [].variance #=> nil
197
+ ```
198
+
199
+ ### HashExtensions
200
+
201
+ ####Except:####
202
+ Use the `except` method to return only key/value pairs not matching certain keys. `Rails Safe`
203
+
204
+ ```ruby
205
+ { foo: 'foo', baz: 'baz', bar: 'bar' }.except(:foo) #=> { baz: 'baz', bar: 'bar' }
206
+ { :foo => 'foo', :baz => 'baz', :bar => 'bar' }.except(:baz, :bar) #=> { :foo => 'foo' }
207
+ {}.except(:foo) #=> {}
208
+ ```
209
+
210
+ ####Only:####
211
+ Use the `only` method to return only key/value pairs matching certain keys. `Rails Safe`
212
+
213
+ ```ruby
214
+ { foo: 'foo', baz: 'baz', bar: 'bar' }.only(:foo) #=> { foo: 'foo' }
215
+ { :foo => 'foo', :baz => 'baz', :bar => 'bar' }.only(:baz, :bar) #=> { :baz => 'baz', :bar => 'bar' }
216
+ {}.only(:foo) #=> {}
217
+ ```
218
+
219
+ ####Rename Keys:####
220
+ Use the `rename_keys` and `rename_keys!` method to rename the keys of a hash.
221
+
222
+ ```ruby
223
+ { foo: 'foo', baz: 'baz' }.rename_keys(foo: :bar) #=> { bar: 'foo', baz: 'baz' }
224
+ { foo: 'foo', 'baz' => 'baz' }.rename_keys(foo: :bar, 'baz' => 'tick') #=> { bar: 'foo', tick: 'baz' }
225
+ ```
226
+
227
+ ####Stringify Keys:####
228
+ Use the `stringify_keys` and `stringify_keys!` method to convert the hash keys to strings. `Rails Safe`
229
+
230
+ ```ruby
231
+ { foo: 'foo', 'bar' => 'bar' }.stringify_keys #=> { 'foo' => 'foo', 'baz' => 'baz' }
232
+ ```
233
+
234
+ ####Symbolize Keys:####
235
+ Use the `symbolize_keys` and `symbolize_keys!` method to convert the hash keys to symbols. `Rails Safe`
236
+
237
+ ```ruby
238
+ { foo: 'foo', 'bar' => 'bar' }.symbolize_keys #=> { foo: 'foo', baz: 'baz' }
239
+ ```
240
+
241
+ ####Symbolize and Underscore Keys:####
242
+ Use the `symbolize_and_underscore_keys` and `symbolize_and_underscore_keys!` method to symbolize and underscore keys.
243
+
244
+ ```ruby
245
+ { 'firstName' => 'example', lastName: 'string' }.symbolize_and_underscore_keys #=> { first_name: 'foo', last_name: 'test' }
246
+ ```
247
+
248
+ ### ObjectExtensions
249
+
250
+ ####Blank:####
251
+ Use the `blank?` method on a object to determine if it is empty or nil. `Rails Safe`
252
+
253
+ ```ruby
254
+ "".blank? #=> true
255
+ "Awesome Sting".blank? #=> false
256
+ ```
257
+
258
+ ####Present:####
259
+ Use the `present?` method on a object to determine if it is not empty or nil. `Rails Safe`
260
+
261
+ ```ruby
262
+ "Awesome Sting".blank? #=> true
263
+ "".present? #=> false
264
+ ```
265
+
266
+ ####Numeric:####
267
+ Use the `numeric?` method to determine whether an object's to_s value is numeric.
268
+
269
+ ```ruby
270
+ "-32.50".numeric? #=> true
271
+ "$2.55".numeric? #=> false
272
+ ```
273
+
274
+ ####Palindrome:####
275
+ Use the `palindrome?` method to determine if an object is a palindrome.
276
+
277
+ ```ruby
278
+ "racecar".palindrome? #=> true
279
+ 12321.palindrome? #=> true
280
+ "example".palindrome? #=> false
281
+ 12345.palindrome? #=> false
282
+ ```
283
+
284
+ ####Try:####
285
+ Use the `try` method on a object to try that method with out raising an error. `Rails Safe`
286
+
287
+ ```ruby
288
+ "example".try(:upcase) #=> "EXAMPLE"
289
+ "example".try(:fake_method) #=> nil
290
+ ```
291
+
292
+ ### NumericExtensions
293
+
294
+ ####Multiple Of:####
295
+ Use the `multiple_of?` method to check if a number is the multiple of another. `Rails Safe`
296
+
297
+ ```ruby
298
+ 9.multiple_of?(3) #=> true
299
+ 7.multiple_of?(3) #=> false
300
+ ```
301
+
302
+ ####Negative:####
303
+ Use the `negative?` method to check if a number is negative.
304
+
305
+ ```ruby
306
+ -1.negative? #=> true
307
+ 1.negative? #=> false
308
+ ```
309
+
310
+ ####Positive:####
311
+ Use the `positive?` method to check if a number is positive.
312
+
313
+ ```ruby
314
+ 1.positive? #=> true
315
+ -1.positive? #=> false
316
+ ```
317
+
318
+ ####To Byte:####
319
+ Use the `to_byte` method to convert a byte size from one unit to another unit.
320
+
321
+ ```ruby
322
+ 1024.to_byte #=> 1 #KB
323
+ 5120.to_byte(:kb, :mb) #=> 5 #MB
324
+ 1.to_byte(:mb, :kb) #=> 1024 #KB
325
+ 80.to_byte(:mb, :gb) #=> 0.1 #GB
326
+ ```
327
+
328
+ ####To Length:####
329
+ Use the `to_length` method to convert a length from one unit to another unit.
330
+
331
+ ```ruby
332
+ 1.to_length #=> 0.039370078740157 #IN
333
+ 10.to_length(:mm, :cm) #=> 1 #CM
334
+ 2.to_length(:mi, :yd) #=> 3520 #IN
335
+ ```
336
+
337
+ ####To Time Unit:####
338
+ Use the `to_time_unit` method to convert a time unit from one unit to another unit.
339
+
340
+ ```ruby
341
+ 120.to_time_unit #=> 2 #MIN
342
+ 2.to_time_unite(:day, :sec) #=> 172800 #SEC
343
+ ```
344
+
345
+ ####To Temperature:####
346
+ Use the `to_temperature` method to convert a temperature from one unit to another unit.
347
+
348
+ ```ruby
349
+ 100.to_temperature #=> 212 #F
350
+ 212.to_temperature(:f, :c) #=> 100 #C
351
+ 212.to_temperature(:fahrenheit, :kelvin) #=> 373.15 #K
352
+ ```
353
+
354
+ ####To Weight:####
355
+ Use the `to_weight` method to convert a weight from one unit to another unit.
356
+
357
+ ```ruby
358
+ 1.to_weight #=> 0.035273961949580004 #OZ
359
+ 2.to_weight(:kg, :lb) #=> 4.4092452436976 #LB
360
+ 3.to_weight(:lb, :kg) #=> 1.3607771100000001 #LB
361
+ ```
362
+
363
+ ### StringExtensions
364
+
365
+ ####Camelize:####
366
+ Use the `camelize` and `camelize!` method to transfrom a string to camelcase. `Rails Safe`
367
+
368
+ ```ruby
369
+ "example_string".camelize #=> "ExampleString"
370
+ "example_string".camelize(:lower) #=> "exampleString"
371
+ ```
372
+
373
+ ####Ends With:####
374
+ Use the `ends_with?` method to determine whether a string ends with a certain value. `Rails Safe`
375
+
376
+ ```ruby
377
+ "example string".ends_with?("g") #=> true
378
+ "example string".ends_with?("ng") #=> true
379
+ "example string".ends_with?("e") #=> false
380
+ ```
381
+
382
+ ####Starts With:####
383
+ Use the `starts_with?` method to determine whether a string starts with a certain value. `Rails Safe`
384
+
385
+ ```ruby
386
+ "example string".starts_with?("e") #=> true
387
+ "example string".starts_with?("ex") #=> true
388
+ "example string".starts_with?("g") #=> false
389
+ ```
390
+
391
+ ####Humanize:####
392
+ Use the `humanize` and `humanize!` method to transform a string to a human readable string. `Rails Safe`
393
+
394
+ ```ruby
395
+ "ExampleString".humanize #=> "Example string"
396
+ "example_string".humanize #=> "Example string"
397
+ ```
398
+
399
+ ####Titleize:####
400
+ Use the `titleize` and `titleize!` method to capitalize each word in a string. `Rails Safe`
401
+
402
+ ```ruby
403
+ "example string".titleize #=> "Example String"
404
+ "example_string".titleize #=> "Example String"
405
+ "ExampleString".titleize #=> "Example String"
406
+ ```
407
+
408
+ ####Underscore:####
409
+ Use the `underscore` and `underscore!` method to transform a string to snakecase. `Rails Safe`
410
+
411
+ ```ruby
412
+ "ExampleString".underscore #=> "example_string"
413
+ "exampleString".underscore #=> "example_string"
414
+ ```
415
+
416
+ ####Domain:####
417
+ Use the `domain` method to extract the domain name from a URL.
418
+
419
+ ```ruby
420
+ "http://www.example.com/fake-page".domain #=> "www.example.com"
421
+ ```
422
+
423
+ ####Downcase:####
424
+ Use the `downcase?` method to determine if all characters are lowercase.
425
+
426
+ ```ruby
427
+ "example".downcase? #=> true
428
+ "Example".downcase? #=> false
429
+ "EXAMPLE".downcase? #=> false
430
+ ```
431
+
432
+ ####Upcase:####
433
+ Use the `upcase?` method to determine if all characters are uppercase.
434
+
435
+ ```ruby
436
+ "EXAMPLE".upcase? #=> true
437
+ "example".upcase? #=> false
438
+ "Example".upcase? #=> false
439
+ ```
440
+
441
+ ####Mixcase:####
442
+ Use the `mixcase?` method to determine if characters are mixedcase.
443
+
444
+ ```ruby
445
+ "Example".mixedcase? #=> true
446
+ "EXAMPLE".mixedcase? #=> false
447
+ "example".mixedcase? #=> false
448
+ ```
449
+
450
+ ####Ellipsize:####
451
+ Use the `ellipsize` method to truncate a string in the middle.
452
+
453
+ **Options**
454
+ * Length: default to 30
455
+ * Offset: default to 4
456
+ * Separator: default to "..."
457
+
458
+ ```ruby
459
+ "example string".ellipsize #=> "example string"
460
+ "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".ellipsize #=> "0123...WXYZ"
461
+ "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".ellipsize(offset: 2, separator: "+++") #=> "01+++YZ"
462
+ ```
463
+
464
+ ####Nix:####
465
+ Use the `nix` and `nix!` method to remove the first instance of a string.
466
+
467
+ ```ruby
468
+ "this thing that thing".nix("thing") #=> "this that thing"
469
+ ```
470
+
471
+ ####GNix:####
472
+ Use the `gnix` and `gnix!` method to remove the every instance of a string.
473
+
474
+ ```ruby
475
+ "this thing that thing".gnix("thing") #=> "this that "
476
+ ```
477
+
478
+ ####Pollute:####
479
+ Use the `pollute` method to pollute the space between every letter in a string, so it will be exempt from any impending string searches.
480
+
481
+ ```ruby
482
+ "test".pollute #=> "t^--^--^e^--^--^s^--^--^t^--^--^"
483
+ "test".pollute("-") #=> "t-e-s-t-"
484
+ ```
485
+
486
+ ####Unpollute:####
487
+ Use the `unpollute` to remove the default or custom pollution character. Can also be used to remove an unwanted character.
488
+
489
+ ```ruby
490
+ "t^--^--^e^--^--^s^--^--^t^--^--^".unpollute #=> "test"
491
+ "t-e-s-t-".unpollute #=> "test"
492
+ ```
493
+
494
+ ####Slugify:####
495
+ Use the `slugify` and `slugify!` method to generate a permalink-style string, with odd characters removed.
496
+
497
+ ```ruby
498
+ "example".slugify #=> "example"
499
+ "example string".slugify #=> "example-string"
500
+ "Example string @@@ test!".slugify #=> "example-string-test"
501
+ ```
502
+
503
+ ####Strip Tags:####
504
+ Use the `strip_tags` and `strip_tags!` method to remove HTML tags from a string.
505
+
506
+ ```ruby
507
+ "example".strip_tags #=> "example"
508
+ "<a href='http://example.com'>click</a>".strip_tags #=> "click"
509
+ "this is <b>bold</b> and <em>emphatic</em>".strip_tags #=> "this is bold and emphatic"
510
+ ```
511
+
512
+ ####Strip Whitespace:####
513
+ Use the `strip_whitespace` and `strip_whitespace!` method removes tab characters and instances of more than one space.
514
+
515
+ ```ruby
516
+ "example string test".strip_whitespace #=> "example string test"
517
+ " this \t is also a test ".strip_whitespace #=> "this is also a test"
518
+ ```
519
+
520
+ ####Truncate Preserving Words:####
521
+ Use the `truncate_preserving_words` method to truncate a string while preserving words.
522
+
523
+ **Options**
524
+ * max_words: default to nil
525
+ * max_characters: default to 30
526
+ * Separator: default to "..."
527
+
528
+ ```ruby
529
+ "example string".truncate_preserving_words #=> "example string"
530
+ "example string test another1 another2 another3".truncate_preserving_words #=> "example string test another1 ..."
531
+ "example string test another1 another2 another3".truncate_preserving_words(max_chars: 10, separator: "+++") #=> "example +++"
532
+ ```
533
+
534
+ ### TimeExtensions
535
+
536
+ ####Format:####
537
+ Use the `format` method on a Date or Time object to format it using a human readable string.
538
+
539
+ **Rules**
540
+ * Characters: a-z 0-9 _
541
+ * Characters can only be used to generate a format part
542
+
543
+ ```ruby
544
+ Time.now.format("year") #=> "2014"
545
+ Time.now.format("month_name day, year hour:minute ampm") #=> "January 09, 2014 02:31 pm"
546
+ ```
547
+
548
+ | Name | Key | Equivalent `strftime` | Result |
549
+ | --- | --- | --- | --- |
550
+ | Month - digits zero-padded | `m` or `month` or `month_zero` | %m | (01..12) |
551
+ | Month - digits unpadded | `mm` or `Month` or `month_unpadded` | %-m | (1..12) |
552
+ | Month - digits blank-padded | `mmm` or `MONTH` or `day_blank` | %_m | ( 1..12) |
553
+ | Month - name | `mmmm` or `month_name` | %B | January |
554
+ | Month - name abbreviated | `mmmmm` or `month_name_abbr` | %b | Jan |
555
+ | Day - digits zero-padded | `d` or `day` or `day_zero` | %d | (01..31) |
556
+ | Day - digits unpadded | `dd` or `Day` or `day_unpadded` | %-d | (1..31) |
557
+ | Day - digits blank-padded | `ddd` or `DAY` or `day_blank` | %_d | ( 1..31) |
558
+ | Day - digits of the year | `dddd` or `day_of_the_year` | %j | (001..366) |
559
+ | Week - starting monday | `wwwww` or `week` | %M | (00..53) |
560
+ | Week - starting sunday | `wwwwww` or `weekday_offset` | %M | (00..53) |
561
+ | Weekday - starting monday | `w` or `weekday` | %M | (1..7) |
562
+ | Weekday - starting sunday | `ww` or `weekday` | %M | (0..6) |
563
+ | Weekday - name | `www` or `weekday_name` | %M | Sunday |
564
+ | Weekday - name abbreviated | `wwww` or `weekday_name_abbr` | %M | Sun |
565
+ | Year - digits two | `yy` or `yr` | %y | (00..99) |
566
+ | Year - digits four | `yyyy` or `year` | %Y | 1999 |
567
+ | Hour - digits zero-padded | `h` or `hour` or `hour_zero` | %H | (00..23) |
568
+ | Hour - digits blank-padded | `hh` or `HOUR` or `hour_blank` | %k | ( 0..23) |
569
+ | Hour - digits zero-padded | `hhh` or `hour_imperical` or `hour_imperical_zero` | %I | (01..12) |
570
+ | Hour - digits blank-padded | `hhhh` or `HOUR_IMPERICAL` or `hour_imperical_blank` | %l | ( 1..12) |
571
+ | Minute - minute | `n` or `minute` | %M | (00..59) |
572
+ | Second - second | `s` or `second` | %S | (00..60) |
573
+ | Meridian - lowercase | `ampm` or `meridian` | %p | am..pm |
574
+ | Meridian - uppercase | `AMPM` or `MERIDIAN` | %P | AM..PM |
575
+ | Time Zone - time zone | `z` or `time_zone` | %z | +0900 |
576
+ | Time Zone - hour and minute offset | `zz` or `time_zone_offset` | %z | +09:00 |
577
+ | Time Zone - hour, minute and second offset | `zzz` or `time_zone_offset_full` | %z | +09:00:00 |
578
+
579
+ ####To Format:####
580
+ Use the `to_format` method on a Date or Time object to format it without having to use `strftime` method.
581
+ **For a full list check out the time extention file.**
582
+
583
+ ```ruby
584
+ Time.now.to_format(:year) #=> "2014"
585
+ Time.now.to_format(:datetime) #=> "January 09, 2014 02:31 pm"
586
+ ```
587
+
588
+ | Name | Key | Equivalent `strftime` | Result |
589
+ | --- | --- | --- | --- |
590
+ | Month - digits zero-padded | `:month` or `:month_zero` | %A | (01..12) |
591
+ | Month - digits unpadded | `:month_unpadded` | %a | (1..12) |
592
+ | Month - digits blank-padded | `:month_blank` | %a | ( 1..12) |
593
+ | Month - name | `:month_name` | %A | January |
594
+ | Month - name abbreviated | `:month_name_abbr` | %a | Jan |
595
+ | Weekday - digits zero-padded | `:weekday_zero` | %A | (01..31) |
596
+ | Weekday - digits unpadded | `:weekday_unpadded` | %a | (1..31) |
597
+ | Weekday - digits blank-padded | `:weekday_blank` | %a | ( 1..31) |
598
+ | Weekday - name | `:weekday_name` | %A | Sunday |
599
+ | Weekday - name abbreviated | `:weekday_name_abbr` | %a | Sun |
600
+ | Year - digits two | `:yr` | %y | (00..99) |
601
+ | Year - digits four | `:year` | %Y | 1999 |
602
+ | Hour - digits zero-padded | `:hour` or `:hour_zero` | %H | (00..23) |
603
+ | Hour - digits blank-padded | `:hour_blank` | %k | ( 0..23) |
604
+ | Hour - digits zero-padded imperical | `:hour_imperical_zero` | %I | (01..12) |
605
+ | Hour - digits blank-padded imperical | `:hour_imperical_blank` | %l | ( 1..12) |
606
+ | Minute - minute | `:minute` | %M | (00..59) |
607
+ | Second - second | `:second` | %S | (00..60) |
608
+ | Time Zone - time zone | `:time_zone` | %z | +0900 |
609
+ | Time Zone - hour and minute offset | `:time_zone_offset` | %z | +09:00 |
610
+ | Time Zone - hour, minute and second offset | `:time_zone_offset_full` | %z | +09:00:00 |
611
+ | Date - name | `:date` | %B %-d, %Y | January 9, 2014 |
612
+ | Date - name abbreviated | `:date_abbr` | %b %-d, %Y | Jan 9, 2014 |
613
+ | Date - iso | `:date_iso` | %Y-%m-%d | 2014-01-09 |
614
+ | Datetime - name | `:datetime` | %B %-d, %Y %H:%M | January 9, 2014 00:31 |
615
+ | Datetime - name abbreviated | `:datetime_abbr` | %b %-d, %Y %H:%M | Jan 9, 2014 00:31 |
616
+ | Datetime - iso | `:datetime_iso` | %Y-%m-%d %H:%M | 2014-01-09 00:31 |
617
+ | Datetime - name imperical | `:datetime_imperical` | %B %-d, %Y %H:%M | January 9, 2014 12:31 am |
618
+ | Datetime - name abbreviated imperical | `:datetime_imperical_abbr` | %b %-d, %Y %H:%M | Jan 9, 2014 12:31 am |
619
+ | Datetime - iso imperical | `:datetime_imperical_iso` | %Y-%m-%d %H:%M | 2014-01-09 12:31 am |
620
+ | Datetime - name time zone | `:datetime_tzn` | %B %-d, %Y %H:%M %Z | January 9, 2014 00:31 UTC |
621
+ | Datetime - name abbreviated time zone | `:datetime_abbr_tzn` | %b %-d, %Y %H:%M %Z | Jan 9, 2014 00:31 UTC |
622
+ | Datetime - iso time zone | `:datetime_iso_tzn` | %Y-%m-%d %H:%M %z | 2014-01-09 00:31 +0000 |
623
+ | Datetime - name imperical time zone | `:datetime_imperical_tzn` | %B %-d, %Y %H:%M %Z | January 9, 2014 12:31 am UTC |
624
+ | Datetime - name abbreviated imperical time zone | `:datetime_imperical_abbr_tzn` | %b %-d, %Y %H:%M %Z | Jan 9, 2014 12:31 am UTC |
625
+ | Datetime - iso imperical time zone | `:datetime_imperical_iso_tzn` | %Y-%m-%d %H:%M %z | 2014-01-09 12:31 am +0000 |
626
+ | Day - name | `:day` | %B %-d | January 9 |
627
+ | Day - name abbreviated | `:day_abbr` | %b %-d | Jan 9 |
628
+ | Day - iso | `:day_iso` | %m-%d | 01-09 |
629
+ | Daytime - name | `:daytime` | %B %-d %H:%M | January 9 00:31 |
630
+ | Daytime - name abbreviated | `:daytime_abbr` | %b %-d %H:%M | Jan 9 00:31 |
631
+ | Daytime - iso | `:daytime_iso` | %m-%d %H:%M | 01-09 00:31 |
632
+ | Daytime - name imperical | `:daytime_imperical` | %B %-d %H:%M | January 9 12:31 am |
633
+ | Daytime - name abbreviated imperical | `:daytime_imperical_abbr` | %b %-d %H:%M | Jan 9 12:31 am |
634
+ | Daytime - iso imperical | `:daytime_imperical_iso` | %m-%d %H:%M | 01-09 12:31 am |
635
+ | Time - zero-padded | `:time` or `:time_zero` | %H:%M | 00:31 |
636
+ | Time - blank-padded | `:time_blank` | %k:%M %z | 0:31 |
637
+ | Time - with time zone | `:time_tz` | %H:%M %z | 00:31 +0000 |
638
+ | Time - with time zone name | `:time_tzn` | %H:%M %Z | 00:31 UTC |
639
+
640
+ ## Contributing
641
+
642
+ 1. Fork it ( http://github.com/<my-github-username>/nobiru/fork )
643
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
644
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
645
+ 4. Push to the branch (`git push origin my-new-feature`)
646
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,15 @@
1
+ class Array
2
+
3
+ def remove_blanks
4
+ reject { |value| value.blank? }
5
+ end
6
+
7
+ def remove_first
8
+ self[1..-1]
9
+ end
10
+
11
+ def remove_last
12
+ self[0...-1]
13
+ end
14
+
15
+ end