flash_extensions 0.0.1 → 1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1206d08de232051d056377e51e2cdb15c0740c9d
4
- data.tar.gz: 3ed1025dfb5654afd9c6efe8eea9d3c14fef1597
3
+ metadata.gz: 090b51df243207aecde9635cad2b62d1308fce33
4
+ data.tar.gz: 48330907ce5b9d46adcf778efbfdfded426f6950
5
5
  SHA512:
6
- metadata.gz: 70b7bbee74fdbcf62f92cfca23349f8d40276e884e7b08878d21f8fcf9300319276a390385d512a75244e4ff7c7c594a6447e0daffbd3b1485454e620ca75094
7
- data.tar.gz: d3a13451ba04b48120a9debd96cabbbe2898c36adea59b5eebfa9819e3d28cf7ca94320b5f830bbd2d796e8edd2e8b7f8fe2e37b39abbcf039230a9d98a95a78
6
+ metadata.gz: 2ea8e99ef235da4cf37b1b071e893b69762f2fa5de1a27db2deeb633ff0c32801249b40ce695ac37d9e25e3dc4b53bace5f115c874aaedb27246d38439a7cb7c
7
+ data.tar.gz: a9bdd4bc914e5ed9daeac0abb464c4fcccdb6fbe48ee435a5cc04e17358d57c732a5458fcb9a1f19b5c87090b043018f720941460eafb928b19fb260ee4084e9
@@ -1,3 +1,5 @@
1
+ before_install:
2
+ - sudo apt-get install libxml2-dev
1
3
  cache: bundler
2
4
  language: ruby
3
5
  notifications:
@@ -7,8 +9,5 @@ notifications:
7
9
  on_failure: change
8
10
  on_success: never
9
11
  rvm:
10
- - '2.1.0'
11
- - '2.0.0'
12
- - '1.9.3'
13
12
  - ruby-head
14
13
  script: 'bundle exec rake'
data/README.md CHANGED
@@ -4,10 +4,16 @@
4
4
  [![Coverage Status](https://coveralls.io/repos/drexed/flash_extensions/badge.png)](https://coveralls.io/r/drexed/flash_extensions)
5
5
  [![Code Climate](https://codeclimate.com/github/drexed/flash_extensions.png)](https://codeclimate.com/github/drexed/flash_extensions)
6
6
 
7
- Flash Extensions is a collection of commonly used object helpers in a ruby based project. It currently includes extensions for: arrays, hash, objects, strings, and time.
7
+ Flash Extensions 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.
8
8
 
9
9
  `Rails Safe` = methods extracted from rails but that do not override that rails method.
10
10
 
11
+ Highly recommended extensions:
12
+ * **Hash:** Hashie - https://github.com/intridea/hashie
13
+ * **String:** Escape Utils - https://github.com/brianmario/escape_utils
14
+ * **String:** Fast Blank - https://github.com/SamSaffron/fast_blank
15
+ * **Translation:** Fast Gettext - https://github.com/grosser/fast_gettext
16
+
11
17
  ## Installation
12
18
 
13
19
  Add this line to your application's Gemfile:
@@ -30,53 +36,142 @@ Or install it yourself as:
30
36
  Use the `remove_blanks` method removes blank elements from an array.
31
37
 
32
38
  ```ruby
33
- ["this", "", "that", nil].remove_blanks => ["this", "that"]
34
- "this is a test".split(" ").remove_blanks => ["this", "is", "a", "test"]
39
+ ["this", "", "that", nil].remove_blanks #=> ["this", "that"]
40
+ "this is a test".split(" ").remove_blanks #=> ["this", "is", "a", "test"]
35
41
  ```
36
42
 
37
43
  ####Remove First Element:####
38
- Use the `remove_first_element` method removes the first element from an array. Like Array.shift, but returns the array instead of removed the element.
44
+ Use the `remove_first` method removes the first element from an array. Like Array.shift, but returns the array instead of removed the element.
39
45
 
40
46
  ```ruby
41
- ["1", "2", "3"].remove_first_element => ["2", "3"]
47
+ ["1", "2", "3"].remove_first #=> ["2", "3"]
42
48
  ```
43
49
 
44
50
  ####Remove Last Element:####
45
- Use the `remove_last_element` method removes the last element from an array. Like Array.pop, but returns the array instead of removed the element.
51
+ Use the `remove_last` method removes the last element from an array. Like Array.pop, but returns the array instead of removed the element.
52
+
53
+ ```ruby
54
+ ["1", "2", "3"].remove_last #=> ["1", "2"]
55
+ ```
56
+
57
+ ### EnumerableExtensions
58
+
59
+ ####Average:####
60
+ Use the `average` method to return the average of a collection of numbers.
61
+
62
+ ```ruby
63
+ [1,2,3].average #=> 2
64
+ [].average #=> 0
65
+ [].average(nil) #=> nil
66
+ ```
67
+
68
+ ####Drop Last:####
69
+ Use the `drop_last` method to drops the last number of elements of a collection.
70
+
71
+ ```ruby
72
+ [1,2,3].drop_last(1) #=> [1,2]
73
+ [].drop_last(3) #=> []
74
+ ```
75
+
76
+ ####Drop Last While:####
77
+ Use the `drop_last_while` method to drops the last number of elements of a collection while it meets a criteria.
46
78
 
47
79
  ```ruby
48
- ["1", "2", "3"].remove_last_element => ["1", "2"]
80
+ [1,2,3].drop_last_while(&:odd?) #=> [1,2]
81
+ [].drop_last_while(&:odd?) #=> []
82
+ ```
83
+
84
+ ####Exactly:####
85
+ Use the `excatly?` method to return if there are exactly the number of an element type.
86
+
87
+ ```ruby
88
+ [1,2,3].excatly?(3) #=> true
89
+ [1,1,3,3].exactly?(2, &:even?) #=> false
90
+ [].exactly?(1) #=> false
91
+ ```
92
+
93
+ ####Several:####
94
+ Use the `several?` method to return if there are several types of an element.
95
+
96
+ ```ruby
97
+ [1,2,3].several? #=> true
98
+ [1,1,3,3].several?(&:even?) #=> false
99
+ [].several? #=> false
100
+ ```
101
+
102
+ ####Sum:####
103
+ Use the `sum` method to to return the sum of a collection of numbers.
104
+
105
+ ```ruby
106
+ [1,2,3].sum #=> 2
107
+ [1,2,3,4].sum #=> 2.5
108
+ [].sum #=> 0
109
+ [].sum(nil) #=> nil
110
+ ```
111
+
112
+ ####Take Last:####
113
+ Use the `take_last` method to return the last number of elements of a collection.
114
+
115
+ ```ruby
116
+ [1,2,3].take_last(2) #=> [2,3]
117
+ [].take_last(3) #=> []
118
+ ```
119
+
120
+ ####Take Last While:####
121
+ Use the `take_last_while` method to return the last number of elements of a collection while it meets a criteria.
122
+
123
+ ```ruby
124
+ [1,2,3,5].take_last_while(&:odd?) #=> [5, 5]
125
+ [].take_last_while(&:odd?) #=> []
49
126
  ```
50
127
 
51
128
  ### HashExtensions
52
129
 
130
+ ####Except:####
131
+ Use the `except` method to return only key/value pairs not matching certain keys.
132
+
133
+ ```ruby
134
+ { foo: 'foo', baz: 'baz', bar: 'bar' }.except(:foo) #=> { baz: 'baz', bar: 'bar' }
135
+ { :foo => 'foo', :baz => 'baz', :bar => 'bar' }.except(:baz, :bar) #=> { :foo => 'foo' }
136
+ {}.except(:foo) #=> {}
137
+ ```
138
+
139
+ ####Only:####
140
+ Use the `only` method to return only key/value pairs matching certain keys.
141
+
142
+ ```ruby
143
+ { foo: 'foo', baz: 'baz', bar: 'bar' }.only(:foo) #=> { foo: 'foo' }
144
+ { :foo => 'foo', :baz => 'baz', :bar => 'bar' }.only(:baz, :bar) #=> { :baz => 'baz', :bar => 'bar' }
145
+ {}.only(:foo) #=> {}
146
+ ```
147
+
53
148
  ####Rename Keys:####
54
- Use the `rename_keys` method to rename the keys of a hash.
149
+ Use the `rename_keys` and `rename_keys!` method to rename the keys of a hash.
55
150
 
56
151
  ```ruby
57
- { foo: 'foo', baz: 'baz' }.rename_keys(foo: :bar) => { bar: 'foo', baz: 'baz' }
58
- { foo: 'foo', 'baz' => 'baz' }.rename_keys(foo: :bar, 'baz' => 'tick') => { bar: 'foo', tick: 'baz' }
152
+ { foo: 'foo', baz: 'baz' }.rename_keys(foo: :bar) #=> { bar: 'foo', baz: 'baz' }
153
+ { foo: 'foo', 'baz' => 'baz' }.rename_keys(foo: :bar, 'baz' => 'tick') #=> { bar: 'foo', tick: 'baz' }
59
154
  ```
60
155
 
61
156
  ####Stringify Keys:####
62
157
  Use the `stringify_keys` and `stringify_keys!` method to convert the hash keys to strings. `Rails Safe`
63
158
 
64
159
  ```ruby
65
- { foo: 'foo', 'bar' => 'bar' }.stringify_keys => { 'foo' => 'foo', 'baz' => 'baz' }
160
+ { foo: 'foo', 'bar' => 'bar' }.stringify_keys #=> { 'foo' => 'foo', 'baz' => 'baz' }
66
161
  ```
67
162
 
68
163
  ####Symbolize Keys:####
69
164
  Use the `symbolize_keys` and `symbolize_keys!` method to convert the hash keys to symbols. `Rails Safe`
70
165
 
71
166
  ```ruby
72
- { foo: 'foo', 'bar' => 'bar' }.symbolize_keys => { foo: 'foo', baz: 'baz' }
167
+ { foo: 'foo', 'bar' => 'bar' }.symbolize_keys #=> { foo: 'foo', baz: 'baz' }
73
168
  ```
74
169
 
75
170
  ####Symbolize and Underscore Keys:####
76
171
  Use the `symbolize_and_underscore_keys` and `symbolize_and_underscore_keys!` method to symbolize and underscore keys.
77
172
 
78
173
  ```ruby
79
- { 'firstName' => 'example', lastName: 'string' }.symbolize_and_underscore_keys => { first_name: 'foo', last_name: 'test' }
174
+ { 'firstName' => 'example', lastName: 'string' }.symbolize_and_underscore_keys #=> { first_name: 'foo', last_name: 'test' }
80
175
  ```
81
176
 
82
177
  ### ObjectExtensions
@@ -85,129 +180,155 @@ Use the `symbolize_and_underscore_keys` and `symbolize_and_underscore_keys!` met
85
180
  Use the `blank?` method on a object to determine if it is empty or nil. `Rails Safe`
86
181
 
87
182
  ```ruby
88
- "".blank? => true
89
- "Awesome Sting".blank? => false
183
+ "".blank? #=> true
184
+ "Awesome Sting".blank? #=> false
90
185
  ```
91
186
 
92
187
  ####Present:####
93
188
  Use the `present?` method on a object to determine if it is not empty or nil. `Rails Safe`
94
189
 
95
190
  ```ruby
96
- "Awesome Sting".blank? => true
97
- "".present? => false
191
+ "Awesome Sting".blank? #=> true
192
+ "".present? #=> false
98
193
  ```
99
194
 
100
195
  ####Numeric:####
101
196
  Use the `numeric?` method to determine whether an object's to_s value is numeric.
102
197
 
103
198
  ```ruby
104
- "-32.50".numeric? => true
105
- "$2.55".numeric? => false
199
+ "-32.50".numeric? #=> true
200
+ "$2.55".numeric? #=> false
106
201
  ```
107
202
 
108
203
  ####Palindrome:####
109
204
  Use the `palindrome?` method to determine if an object is a palindrome.
110
205
 
111
206
  ```ruby
112
- "racecar".palindrome? => true
113
- 12321.palindrome? => true
114
- "example".palindrome? => false
115
- 12345.palindrome? => false
207
+ "racecar".palindrome? #=> true
208
+ 12321.palindrome? #=> true
209
+ "example".palindrome? #=> false
210
+ 12345.palindrome? #=> false
116
211
  ```
117
212
 
118
213
  ####Try:####
119
214
  Use the `try` method on a object to try that method with out raising an error. `Rails Safe`
120
215
 
121
216
  ```ruby
122
- "example".try(:upcase) => "EXAMPLE"
123
- "example".try(:fake_method) => nil
217
+ "example".try(:upcase) #=> "EXAMPLE"
218
+ "example".try(:fake_method) #=> nil
219
+ ```
220
+
221
+ ### NumericExtensions
222
+
223
+ ####Multiple Of:####
224
+ Use the `multiple_of?` method to check if a number is the multiple of another. `Rails Safe`
225
+
226
+ ```ruby
227
+ 9.multiple_of?(3) #=> true
228
+ 7.multiple_of?(3) #=> false
229
+ ```
230
+
231
+ ####Negative:####
232
+ Use the `negative?` method to check if a number is negative.
233
+
234
+ ```ruby
235
+ -1.negative? #=> true
236
+ 1.negative? #=> false
237
+ ```
238
+
239
+ ####Positive:####
240
+ Use the `positive?` method to check if a number is positive.
241
+
242
+ ```ruby
243
+ 1.positive? #=> true
244
+ -1.positive? #=> false
124
245
  ```
125
246
 
126
247
  ### StringExtensions
127
248
 
128
249
  ####Camelize:####
129
- Use the `camelize` method to transfrom a string to camelcase. `Rails Safe`
250
+ Use the `camelize` and `camelize!` method to transfrom a string to camelcase. `Rails Safe`
130
251
 
131
252
  ```ruby
132
- "example_string".camelize => "ExampleString"
133
- "example_string".camelize(:lower) => "exampleString"
253
+ "example_string".camelize #=> "ExampleString"
254
+ "example_string".camelize(:lower) #=> "exampleString"
134
255
  ```
135
256
 
136
257
  ####Ends With:####
137
258
  Use the `ends_with?` method to determine whether a string ends with a certain value. `Rails Safe`
138
259
 
139
260
  ```ruby
140
- "example string".ends_with?("g") => true
141
- "example string".ends_with?("ng") => true
142
- "example string".ends_with?("e") => false
261
+ "example string".ends_with?("g") #=> true
262
+ "example string".ends_with?("ng") #=> true
263
+ "example string".ends_with?("e") #=> false
143
264
  ```
144
265
 
145
266
  ####Starts With:####
146
267
  Use the `starts_with?` method to determine whether a string starts with a certain value. `Rails Safe`
147
268
 
148
269
  ```ruby
149
- "example string".starts_with?("e") => true
150
- "example string".starts_with?("ex") => true
151
- "example string".starts_with?("g") => false
270
+ "example string".starts_with?("e") #=> true
271
+ "example string".starts_with?("ex") #=> true
272
+ "example string".starts_with?("g") #=> false
152
273
  ```
153
274
 
154
275
  ####Humanize:####
155
- Use the `humanize` method to transform a string to a human readable string. `Rails Safe`
276
+ Use the `humanize` and `humanize!` method to transform a string to a human readable string. `Rails Safe`
156
277
 
157
278
  ```ruby
158
- "ExampleString".humanize => "Example string"
159
- "example_string".humanize => "Example string"
279
+ "ExampleString".humanize #=> "Example string"
280
+ "example_string".humanize #=> "Example string"
160
281
  ```
161
282
 
162
283
  ####Titleize:####
163
- Use the `titleize` method to capitalize each word in a string. `Rails Safe`
284
+ Use the `titleize` and `titleize!` method to capitalize each word in a string. `Rails Safe`
164
285
 
165
286
  ```ruby
166
- "example string".titleize => "Example String"
167
- "example_string".titleize => "Example String"
168
- "ExampleString".titleize => "Example String"
287
+ "example string".titleize #=> "Example String"
288
+ "example_string".titleize #=> "Example String"
289
+ "ExampleString".titleize #=> "Example String"
169
290
  ```
170
291
 
171
292
  ####Underscore:####
172
- Use the `underscore` method to transform a string to snakecase. `Rails Safe`
293
+ Use the `underscore` and `underscore!` method to transform a string to snakecase. `Rails Safe`
173
294
 
174
295
  ```ruby
175
- "ExampleString".underscore => "example_string"
176
- "exampleString".underscore => "example_string"
296
+ "ExampleString".underscore #=> "example_string"
297
+ "exampleString".underscore #=> "example_string"
177
298
  ```
178
299
 
179
300
  ####Domain:####
180
301
  Use the `domain` method to extract the domain name from a URL.
181
302
 
182
303
  ```ruby
183
- "http://www.example.com/fake-page".domain => "www.example.com"
304
+ "http://www.example.com/fake-page".domain #=> "www.example.com"
184
305
  ```
185
306
 
186
307
  ####Downcase:####
187
308
  Use the `downcase?` method to determine if all characters are lowercase.
188
309
 
189
310
  ```ruby
190
- "example".downcase? => true
191
- "Example".downcase? => false
192
- "EXAMPLE".downcase? => false
311
+ "example".downcase? #=> true
312
+ "Example".downcase? #=> false
313
+ "EXAMPLE".downcase? #=> false
193
314
  ```
194
315
 
195
316
  ####Upcase:####
196
317
  Use the `upcase?` method to determine if all characters are uppercase.
197
318
 
198
319
  ```ruby
199
- "EXAMPLE".upcase? => true
200
- "example".upcase? => false
201
- "Example".upcase? => false
320
+ "EXAMPLE".upcase? #=> true
321
+ "example".upcase? #=> false
322
+ "Example".upcase? #=> false
202
323
  ```
203
324
 
204
325
  ####Mixcase:####
205
326
  Use the `mixcase?` method to determine if characters are mixedcase.
206
327
 
207
328
  ```ruby
208
- "Example".mixedcase? => true
209
- "EXAMPLE".mixedcase? => false
210
- "example".mixedcase? => false
329
+ "Example".mixedcase? #=> true
330
+ "EXAMPLE".mixedcase? #=> false
331
+ "example".mixedcase? #=> false
211
332
  ```
212
333
 
213
334
  ####Ellipsize:####
@@ -219,65 +340,65 @@ Use the `ellipsize` method to truncate a string in the middle.
219
340
  * Separator: default to "..."
220
341
 
221
342
  ```ruby
222
- "example string".ellipsize => "example string"
223
- "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".ellipsize => "0123...WXYZ"
224
- "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".ellipsize(offset: 2, separator: "+++") => "01+++YZ"
343
+ "example string".ellipsize #=> "example string"
344
+ "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".ellipsize #=> "0123...WXYZ"
345
+ "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".ellipsize(offset: 2, separator: "+++") #=> "01+++YZ"
225
346
  ```
226
347
 
227
348
  ####Nix:####
228
- Use the `nix` method to remove the first instance of a string.
349
+ Use the `nix` and `nix!` method to remove the first instance of a string.
229
350
 
230
351
  ```ruby
231
- "this thing that thing".nix("thing") => "this that thing"
352
+ "this thing that thing".nix("thing") #=> "this that thing"
232
353
  ```
233
354
 
234
355
  ####GNix:####
235
- Use the `gnix` method to remove the every instance of a string.
356
+ Use the `gnix` and `gnix!` method to remove the every instance of a string.
236
357
 
237
358
  ```ruby
238
- "this thing that thing".gnix("thing") => "this that "
359
+ "this thing that thing".gnix("thing") #=> "this that "
239
360
  ```
240
361
 
241
362
  ####Pollute:####
242
363
  Use the `pollute` method to pollute the space between every letter in a string, so it will be exempt from any impending string searches.
243
364
 
244
365
  ```ruby
245
- "test".pollute => "t^--^--^e^--^--^s^--^--^t^--^--^"
246
- "test".pollute("-") => "t-e-s-t-"
366
+ "test".pollute #=> "t^--^--^e^--^--^s^--^--^t^--^--^"
367
+ "test".pollute("-") #=> "t-e-s-t-"
247
368
  ```
248
369
 
249
370
  ####Unpollute:####
250
371
  Use the `unpollute` to remove the default or custom pollution character. Can also be used to remove an unwanted character.
251
372
 
252
373
  ```ruby
253
- "t^--^--^e^--^--^s^--^--^t^--^--^".unpollute => "test"
254
- "t-e-s-t-".unpollute => "test"
374
+ "t^--^--^e^--^--^s^--^--^t^--^--^".unpollute #=> "test"
375
+ "t-e-s-t-".unpollute #=> "test"
255
376
  ```
256
377
 
257
378
  ####Slugify:####
258
- Use the `slugify` method to generate a permalink-style string, with odd characters removed.
379
+ Use the `slugify` and `slugify!` method to generate a permalink-style string, with odd characters removed.
259
380
 
260
381
  ```ruby
261
- "example".slugify => "example"
262
- "example string".slugify => "example-string"
263
- "Example string @@@ test!".slugify => "example-string-test"
382
+ "example".slugify #=> "example"
383
+ "example string".slugify #=> "example-string"
384
+ "Example string @@@ test!".slugify #=> "example-string-test"
264
385
  ```
265
386
 
266
387
  ####Strip Tags:####
267
- Use the `strip_tags` method to remove HTML tags from a string.
388
+ Use the `strip_tags` and `strip_tags!` method to remove HTML tags from a string.
268
389
 
269
390
  ```ruby
270
- "example".strip_tags => "example"
271
- "<a href='http://example.com'>click</a>".strip_tags => "click"
272
- "this is <b>bold</b> and <em>emphatic</em>".strip_tags => "this is bold and emphatic"
391
+ "example".strip_tags #=> "example"
392
+ "<a href='http://example.com'>click</a>".strip_tags #=> "click"
393
+ "this is <b>bold</b> and <em>emphatic</em>".strip_tags #=> "this is bold and emphatic"
273
394
  ```
274
395
 
275
396
  ####Strip Whitespace:####
276
- Use the `strip_whitespace` method removes tab characters and instances of more than one space.
397
+ Use the `strip_whitespace` and `strip_whitespace!` method removes tab characters and instances of more than one space.
277
398
 
278
399
  ```ruby
279
- "example string test".strip_whitespace => "example string test"
280
- " this \t is also a test ".strip_whitespace => "this is also a test"
400
+ "example string test".strip_whitespace #=> "example string test"
401
+ " this \t is also a test ".strip_whitespace #=> "this is also a test"
281
402
  ```
282
403
 
283
404
  ####Truncate Preserving Words:####
@@ -289,9 +410,9 @@ Use the `truncate_preserving_words` method to truncate a string while preserving
289
410
  * Separator: default to "..."
290
411
 
291
412
  ```ruby
292
- "example string".truncate_preserving_words => "example string"
293
- "example string test another1 another2 another3".truncate_preserving_words => "example string test another1 ..."
294
- "example string test another1 another2 another3".truncate_preserving_words(max_chars: 10, separator: "+++") => "example +++"
413
+ "example string".truncate_preserving_words #=> "example string"
414
+ "example string test another1 another2 another3".truncate_preserving_words #=> "example string test another1 ..."
415
+ "example string test another1 another2 another3".truncate_preserving_words(max_chars: 10, separator: "+++") #=> "example +++"
295
416
  ```
296
417
 
297
418
  ### TimeExtensions
@@ -304,8 +425,8 @@ Use the `format` method on a Date or Time object to format it using a human read
304
425
  * Characters can only be used to generate a format part
305
426
 
306
427
  ```ruby
307
- Time.now.format("year") => "2014"
308
- Time.now.format("month_name day, year hour:minute ampm") => "January 09, 2014 02:31 pm"
428
+ Time.now.format("year") #=> "2014"
429
+ Time.now.format("month_name day, year hour:minute ampm") #=> "January 09, 2014 02:31 pm"
309
430
  ```
310
431
 
311
432
  | Name | Key | Equivalent `strftime` | Result |
@@ -343,8 +464,8 @@ Time.now.format("month_name day, year hour:minute ampm") => "January 09, 2014 02
343
464
  Use the `to_format` method on a Date or Time object to format it without having to use `strftime` method.
344
465
 
345
466
  ```ruby
346
- Time.now.to_format(:year) => "2014"
347
- Time.now.to_format(:datetime) => "January 09, 2014 02:31 pm"
467
+ Time.now.to_format(:year) #=> "2014"
468
+ Time.now.to_format(:datetime) #=> "January 09, 2014 02:31 pm"
348
469
  ```
349
470
 
350
471
  | Name | Key | Equivalent `strftime` | Result |