active_object 1.2.1 → 1.3.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 +4 -4
- data/README.md +21 -11
- data/lib/active_object/numeric.rb +5 -5
- data/lib/active_object/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68ffe211f664a7cd4a2fe3463d03625e1f0e5b61
|
4
|
+
data.tar.gz: 8c0eed8e763427704f8f48e13f8f546eccf123d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64f1721c2b934fb00cc8d0df125946db44ed9cba4ff6e09f6daf32a109b296a3fa3ad648a1d6bd3c6df25eba6c95096c9c3fc444a1475786cc658f58c2986785
|
7
|
+
data.tar.gz: 825ab8ed4749a483ed9a2e981578a8e0b73767ddeb0ce1b1c721e5c9a0b1f6330f025d6b96a146694670b9926634c9ee17f9a8e3ae017b8ae1e0ae701de81748
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
[](https://travis-ci.org/drexed/active_object)
|
5
5
|
[](https://coveralls.io/r/drexed/active_object)
|
6
6
|
|
7
|
-
ActiveObject is a collection of commonly used object helpers in a ruby based project.
|
7
|
+
ActiveObject is a collection of commonly used object helpers in a ruby based project.
|
8
8
|
|
9
9
|
`Rails Safe` = methods extracted from rails but that do not override that rails method.
|
10
10
|
|
@@ -28,9 +28,19 @@ Or install it yourself as:
|
|
28
28
|
|
29
29
|
$ gem install active_object
|
30
30
|
|
31
|
-
##
|
31
|
+
## Table of Contents
|
32
32
|
|
33
|
-
|
33
|
+
* [Array](#array)
|
34
|
+
* [Enumerable](#enumerable)
|
35
|
+
* [Hash](#hash)
|
36
|
+
* [Integer](#integer)
|
37
|
+
* [Numeric](#numeric)
|
38
|
+
* [Object](#object)
|
39
|
+
* [Range](#Rrange)
|
40
|
+
* [String](#string)
|
41
|
+
* [Time](#time)
|
42
|
+
|
43
|
+
## Array
|
34
44
|
|
35
45
|
####Delete First:####
|
36
46
|
`delete_first` and `delete_first!` removes the first element from an array. Like Array.shift, but returns the array instead of the removed element.
|
@@ -122,7 +132,7 @@ Or install it yourself as:
|
|
122
132
|
["one", "two", "three"].to_sentence(words_connector: ' or ', last_word_connector: ' or at least ') #=> "one or two or at least three"
|
123
133
|
```
|
124
134
|
|
125
|
-
|
135
|
+
## Enumerable
|
126
136
|
|
127
137
|
####Difference:####
|
128
138
|
`difference` returns the difference of a collection of numbers.
|
@@ -326,7 +336,7 @@ Or install it yourself as:
|
|
326
336
|
[1,2,6].variance #=> 7
|
327
337
|
```
|
328
338
|
|
329
|
-
|
339
|
+
## Hash
|
330
340
|
|
331
341
|
####Assert Valid Keys:####
|
332
342
|
`assert_valid_keys` raises an error if key is not included in a list of keys. `Rails Safe`
|
@@ -452,7 +462,7 @@ h.slice!(:a, :b) #=> { c: 3, d: 4 }
|
|
452
462
|
{ foo: "bar", baz: "boo" }.transform_values { |v| v.to_s.upcase } #=> {foo: "BAR", baz: "BOO" }
|
453
463
|
```
|
454
464
|
|
455
|
-
|
465
|
+
## Integer
|
456
466
|
|
457
467
|
####Time:####
|
458
468
|
`time` returns a Time object for the given Integer.
|
@@ -461,7 +471,7 @@ h.slice!(:a, :b) #=> { c: 3, d: 4 }
|
|
461
471
|
3.time #=> "1969-12-31 19:00:03.000000000 -0500"
|
462
472
|
```
|
463
473
|
|
464
|
-
|
474
|
+
## Numeric
|
465
475
|
|
466
476
|
####Add:####
|
467
477
|
`add` returns the sum of two numbers.
|
@@ -938,7 +948,7 @@ h.slice!(:a, :b) #=> { c: 3, d: 4 }
|
|
938
948
|
3.years_in_seconds #=> 94672800.0
|
939
949
|
```
|
940
950
|
|
941
|
-
|
951
|
+
## Object
|
942
952
|
|
943
953
|
####Blank:####
|
944
954
|
`blank?` determines if an object is empty or nil. `Rails Safe`
|
@@ -982,7 +992,7 @@ h.slice!(:a, :b) #=> { c: 3, d: 4 }
|
|
982
992
|
"example".try(:fake_method) #=> nil
|
983
993
|
```
|
984
994
|
|
985
|
-
|
995
|
+
## Range
|
986
996
|
|
987
997
|
####Include With Range:####
|
988
998
|
`include_with_range?` determines if a range includes another range. `Rails Safe`
|
@@ -1001,7 +1011,7 @@ h.slice!(:a, :b) #=> { c: 3, d: 4 }
|
|
1001
1011
|
(1..5).overlaps?(7..9) # => false
|
1002
1012
|
```
|
1003
1013
|
|
1004
|
-
|
1014
|
+
## String
|
1005
1015
|
|
1006
1016
|
####Any:####
|
1007
1017
|
`any?` determines if a string includes a set of string(s).
|
@@ -1320,7 +1330,7 @@ h.slice!(:a, :b) #=> { c: 3, d: 4 }
|
|
1320
1330
|
"Example".upcase? #=> false
|
1321
1331
|
```
|
1322
1332
|
|
1323
|
-
|
1333
|
+
## Time
|
1324
1334
|
|
1325
1335
|
####Format:####
|
1326
1336
|
`format` converts a Date or Time object to format it using a human readable string.
|
@@ -345,7 +345,7 @@ class Numeric
|
|
345
345
|
|
346
346
|
unless valid_keys.include?(from) && valid_keys.include?(to)
|
347
347
|
raise ArgumentError,
|
348
|
-
"Unknown key(s):
|
348
|
+
"Unknown key(s): from: #{from.inspect} and to: #{to.inspect}. Valid keys are: #{valid_keys.map(&:inspect).join(', ')}"
|
349
349
|
end
|
350
350
|
|
351
351
|
to_f * 1.send("#{from}_in_bytes") / 1.send("#{to}_in_bytes")
|
@@ -375,7 +375,7 @@ class Numeric
|
|
375
375
|
|
376
376
|
unless valid_keys.include?(from) && valid_keys.include?(to)
|
377
377
|
raise ArgumentError,
|
378
|
-
"Unknown key(s):
|
378
|
+
"Unknown key(s): from: #{from.inspect} and to: #{to.inspect}. Valid keys are: #{valid_keys.map(&:inspect).join(', ')}"
|
379
379
|
end
|
380
380
|
|
381
381
|
case to
|
@@ -414,7 +414,7 @@ class Numeric
|
|
414
414
|
|
415
415
|
unless valid_keys.include?(from) && valid_keys.include?(to)
|
416
416
|
raise ArgumentError,
|
417
|
-
"Unknown key(s):
|
417
|
+
"Unknown key(s): from: #{from.inspect} and to: #{to.inspect}. Valid keys are: #{valid_keys.map(&:inspect).join(', ')}"
|
418
418
|
end
|
419
419
|
|
420
420
|
case to
|
@@ -460,7 +460,7 @@ class Numeric
|
|
460
460
|
|
461
461
|
unless valid_keys.include?(from) && valid_keys.include?(to)
|
462
462
|
raise ArgumentError,
|
463
|
-
"Unknown key(s):
|
463
|
+
"Unknown key(s): from: #{from.inspect} and to: #{to.inspect}. Valid keys are: #{valid_keys.map(&:inspect).join(', ')}"
|
464
464
|
end
|
465
465
|
|
466
466
|
case to
|
@@ -490,7 +490,7 @@ class Numeric
|
|
490
490
|
|
491
491
|
unless valid_keys.include?(from) && valid_keys.include?(to)
|
492
492
|
raise ArgumentError,
|
493
|
-
"Unknown key(s):
|
493
|
+
"Unknown key(s): from: #{from.inspect} and to: #{to.inspect}. Valid keys are: #{valid_keys.map(&:inspect).join(', ')}"
|
494
494
|
end
|
495
495
|
|
496
496
|
to_f * 1.send("#{from}_in_seconds") / 1.send("#{to}_in_seconds")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_object
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Gomez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|