true_string 0.0.1 → 0.0.2
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 +9 -0
- data/lib/true_string.rb +13 -0
- data/lib/true_string/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: f501320bc3f0d78799ec13188ac0905096d19e1c
|
4
|
+
data.tar.gz: 88e7f0ca283fd81dbbbe518155ba39e553003c39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: debf85516bc4b68b58af00b5a2c11a1379f6fd2df7760c7f2e32aeb162d21e10089f4d1f1f7b4e5a9b8d3b0b435d1411dd3d0b89c2538746f239136aca4cce5a
|
7
|
+
data.tar.gz: a3262ce2816bb9a8c542dff774ba7ce77d9636012e1aa9bbf1d3ce05268a63b18cabb00164d2044b6cc2156d51163bfaaa94ccadacc8ac908edcd7780e9645d6
|
data/README.md
CHANGED
@@ -16,6 +16,15 @@ Collection of strings which can be translated into truth values, `true` and `fal
|
|
16
16
|
|
17
17
|
An string can not return `true` for both `#truthy?` and `#falsey?`, but may return `false` for both of them.
|
18
18
|
|
19
|
+
`Object` also has `truthy?` and `falsey?`.
|
20
|
+
|
21
|
+
```rb
|
22
|
+
Object.truthy?
|
23
|
+
nil.falsey?
|
24
|
+
```
|
25
|
+
|
26
|
+
The methods returns `true` if the receiver is truthy or falsey respectively.
|
27
|
+
|
19
28
|
## Installation
|
20
29
|
|
21
30
|
Add this line to your application's Gemfile:
|
data/lib/true_string.rb
CHANGED
@@ -6,15 +6,18 @@ module TrueString
|
|
6
6
|
pairs = [
|
7
7
|
%w(true false),
|
8
8
|
%w(TRUE FALSE),
|
9
|
+
%w(True False),
|
9
10
|
%w(t f),
|
10
11
|
%w(T F),
|
11
12
|
%w(1 0),
|
12
13
|
%w(yes no),
|
13
14
|
%w(YES NO),
|
15
|
+
%w(Yes No),
|
14
16
|
%w(y n),
|
15
17
|
%w(Y N),
|
16
18
|
%w(on off),
|
17
19
|
%w(ON OFF),
|
20
|
+
%w(On Off),
|
18
21
|
%w(○ ×),
|
19
22
|
%w(⭕️ ❌),
|
20
23
|
%w(✅ ❎),
|
@@ -41,3 +44,13 @@ class String
|
|
41
44
|
TrueString::TRUTH_TABLE[self] == false
|
42
45
|
end
|
43
46
|
end
|
47
|
+
|
48
|
+
class Object
|
49
|
+
def truthy?
|
50
|
+
!!self
|
51
|
+
end
|
52
|
+
|
53
|
+
def falsey?
|
54
|
+
!self
|
55
|
+
end
|
56
|
+
end
|
data/lib/true_string/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: true_string
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Soutaro Matsumoto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|