vehicle_coding_ph 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +5 -2
- data/lib/vehicle_coding_ph/checker.rb +5 -7
- data/lib/vehicle_coding_ph/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3cc0616b90c86b72c8cca57b1c565f60f06d8d8516969eb87c4ce47c21999556
|
4
|
+
data.tar.gz: 0d4b7e37ae873cafa2f5a09bc1991f7b3e016c5579fff48ad8ff2418f401aa68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ad16c1745314249a63a32370c8d52d46ce287e1fbd923c6af46c0d44d897ef50c7380a098f8c93fbcb0163120b6ce27e8a807e2b7966d5fe134cd398ff1bb07
|
7
|
+
data.tar.gz: 67b1f47d2469f4a620e2aef2c64958d0f7113e4cad2ba0650a3045cb3f966a80a84c59a4475dd8d8140462916bc6df446ece9df856ce9efa609bd4147dd6bf63
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -24,7 +24,10 @@ Or install it yourself as:
|
|
24
24
|
|
25
25
|
```ruby
|
26
26
|
# Returns true if allowed to drive today; otherwise it's false
|
27
|
-
VehicleCodingPh::Checker.(
|
27
|
+
VehicleCodingPh::Checker.(
|
28
|
+
plate_number_of_your_vehicle,
|
29
|
+
date # if not passed, defaults to date today
|
30
|
+
)
|
28
31
|
```
|
29
32
|
|
30
33
|
## Development
|
@@ -35,7 +38,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
35
38
|
|
36
39
|
## Contributing
|
37
40
|
|
38
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/
|
41
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/vehicle_coding_ph. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
39
42
|
|
40
43
|
## License
|
41
44
|
|
@@ -1,18 +1,16 @@
|
|
1
1
|
module VehicleCodingPh
|
2
2
|
class Checker
|
3
3
|
|
4
|
-
def self.call(plate_no)
|
5
|
-
|
6
|
-
|
7
|
-
return true if weekend?(today)
|
4
|
+
def self.call(plate_no, date = Date.today)
|
5
|
+
return true if weekend?(date)
|
8
6
|
|
9
7
|
last_digit = plate_no[-1]
|
10
|
-
|
8
|
+
day_today = Date::DAYNAMES[date.cwday]
|
11
9
|
|
12
10
|
mapping = VehicleCodingPh::PLATE_TO_DAY_MAPPING.
|
13
|
-
select { |day,
|
11
|
+
select { |day, digits| day == day_today }
|
14
12
|
|
15
|
-
!mapping[
|
13
|
+
!mapping[day_today].include?(last_digit)
|
16
14
|
end
|
17
15
|
|
18
16
|
def self.weekend?(date)
|