remistify 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 +7 -0
- data/lib/remistify.rb +36 -0
- metadata +43 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5388150799e603899099aec198ba8d34e09eba56fec398b930eb556e9dfc11a7
|
4
|
+
data.tar.gz: efd51a44adb16218e1adf6840070fab34f271d1bb2393d51cb8f0c127a8306ce
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f75db3497019f23222c84a022e9bf4618fac8e3b4d678b8eec9160eabed299cccd04269d2150fa0fc962208ae3afb2640b6027ac909d336a51beff6c8a43fae2
|
7
|
+
data.tar.gz: b2ea6e31ece07ed05a1699cfe341c9621c266d43d602294b0d4156ea1b234fe47836bafef81e5cba16438808b10c45049836dbe4fccdec93462f9d23e309a27b
|
data/lib/remistify.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'time_constants'
|
2
|
+
class Remistify
|
3
|
+
# Calculates expiration based on remiss
|
4
|
+
# @param remiss [integer] number of remaining issues to fulfill
|
5
|
+
# @param issues [integer] issues per cycle
|
6
|
+
# @param cycle [integer] integer value of time measurement for duration of subscription cycle (T_1_YEAR)
|
7
|
+
# @param from [String] specify a starting point in time
|
8
|
+
# @return [DateTime]
|
9
|
+
def self.expiration(remiss, issues, cycle, from=nil, tz=nil)
|
10
|
+
seconds_per_cycle = cycle.to_i / issues.to_i
|
11
|
+
expiration = nil
|
12
|
+
if from
|
13
|
+
expiration = DateTime.parse(from).to_time
|
14
|
+
else
|
15
|
+
expiration = Time.now
|
16
|
+
if tz
|
17
|
+
expiration = expiration.in_time_zone(tz)
|
18
|
+
end #/if
|
19
|
+
end #/if-else
|
20
|
+
|
21
|
+
range = (1..remiss)
|
22
|
+
if remiss <= 0
|
23
|
+
range = (remiss..-1) # ignore 0
|
24
|
+
end#/if
|
25
|
+
|
26
|
+
range.each do |i|
|
27
|
+
if remiss >= 1
|
28
|
+
expiration = expiration + seconds_per_cycle
|
29
|
+
else
|
30
|
+
expiration = expiration - seconds_per_cycle
|
31
|
+
end #/if-else
|
32
|
+
end #/each
|
33
|
+
|
34
|
+
return expiration
|
35
|
+
end #/def
|
36
|
+
end #/class
|
metadata
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: remistify
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andrei Merlescu
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-12-21 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Calculates expiration based on remiss.
|
14
|
+
email: andrei@merlescu.net
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/remistify.rb
|
20
|
+
homepage: https://github.com/amerlescucodez/remistify
|
21
|
+
licenses:
|
22
|
+
- GPLv3
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubygems_version: 3.0.3
|
40
|
+
signing_key:
|
41
|
+
specification_version: 4
|
42
|
+
summary: Calculates expiration based on remiss.
|
43
|
+
test_files: []
|