ce-bucketize 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ce-bucketize.gemspec +1 -1
- data/lib/ce-bucketize/hourly_values.rb +8 -5
- data/lib/ce-bucketize/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: badfc713d027be682e490aa0508bbce6947d58d5
|
4
|
+
data.tar.gz: 8f7b6f00806a3b43347caf8190edd25963b2c2ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a50d52f8d9a43b540d7a2a30ad1e97e1114f17a6d57524259b1700f454e48bf1133af5c92b255c0e0325011cb116a9f0a85fbaab3c7cd6c494011e445fc2bd77
|
7
|
+
data.tar.gz: 2f8a08643d25f36f2957f23dd8c7bf2dbda51a5c71cacf22b1cb2942491de5131b2fa3864c1a01598e1dd9432c84252873f946e04a8d015f5f4a9f77d9bda5a1
|
data/ce-bucketize.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = 'ce-bucketize'
|
8
8
|
spec.version = Bucketize::VERSION
|
9
9
|
spec.authors = ['TCSASSEMBLER','brandon.jahner']
|
10
|
-
spec.email = ['TCSASSEMBLER@topcoder.com','bjahner@
|
10
|
+
spec.email = ['TCSASSEMBLER@topcoder.com','bjahner@gmail.com']
|
11
11
|
|
12
12
|
spec.summary = %q{Aggregates consumption data and calculates costs based on predefined tariffs.}
|
13
13
|
|
@@ -16,6 +16,9 @@ module Bucketize
|
|
16
16
|
# hour in seconds
|
17
17
|
HOUR = 3600
|
18
18
|
|
19
|
+
# The maximum integer for the current machine.
|
20
|
+
MAX_INT = (2**((0.size * 8) - 1)) - 1
|
21
|
+
|
19
22
|
# The length (in seconds) of the maximum allowed gap in input data.
|
20
23
|
attr_accessor :max_gap_length
|
21
24
|
|
@@ -40,8 +43,8 @@ module Bucketize
|
|
40
43
|
end
|
41
44
|
|
42
45
|
@gb_data_description = gb_data_description
|
43
|
-
@from = from
|
44
|
-
@to = to
|
46
|
+
@from = from || Time.at(0)
|
47
|
+
@to = to || Time.at(MAX_INT)
|
45
48
|
@max_gap_length = 4 * HOUR
|
46
49
|
@readings = prepare_readings
|
47
50
|
end
|
@@ -62,8 +65,8 @@ module Bucketize
|
|
62
65
|
d0 = current_reading.time_duration.to_f # duration of the first reading
|
63
66
|
# last reading time.
|
64
67
|
tn = @readings.last.time_start + @readings.last.time_duration - HOUR
|
65
|
-
hour_start = @from
|
66
|
-
last_hour_start =
|
68
|
+
hour_start = [@from, t0].max # will point to the current hour start
|
69
|
+
last_hour_start = [@to - HOUR, tn].min # the last hour_start
|
67
70
|
d = (t0 + d0 - hour_start).to_f # remaining seconds from the current reading.
|
68
71
|
rem = (d/d0) * current_reading.value # remaining value from the current reading.
|
69
72
|
hf = 1.to_f # remaining fraction of hour for the current hour value
|
@@ -191,7 +194,7 @@ module Bucketize
|
|
191
194
|
return i
|
192
195
|
end
|
193
196
|
end
|
194
|
-
|
197
|
+
nil
|
195
198
|
end
|
196
199
|
|
197
200
|
# Internal: interpolates the given gaps in the readings.
|
data/lib/ce-bucketize/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ce-bucketize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TCSASSEMBLER
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-05-
|
12
|
+
date: 2015-05-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -116,7 +116,7 @@ description: |-
|
|
116
116
|
subject to data completeness checks and multiply them with a single tariff number.
|
117
117
|
email:
|
118
118
|
- TCSASSEMBLER@topcoder.com
|
119
|
-
- bjahner@
|
119
|
+
- bjahner@gmail.com
|
120
120
|
executables: []
|
121
121
|
extensions: []
|
122
122
|
extra_rdoc_files: []
|