percentage_in_time 0.0.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.
- data/lib/percentage_in_time.rb +13 -0
- metadata +47 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require 'date'
|
|
2
|
+
|
|
3
|
+
class PercentageInTime
|
|
4
|
+
|
|
5
|
+
def self.between(start_date, end_date)
|
|
6
|
+
date_now = Date.today
|
|
7
|
+
initial_diff = end_date - start_date
|
|
8
|
+
diff_now = end_date - date_now
|
|
9
|
+
percentage = (1-(diff_now/initial_diff))*100
|
|
10
|
+
percentage > 100 ? 100 : percentage.to_i
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: percentage_in_time
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.0
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Luís Ramalho
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2013-09-12 00:00:00.000000000 Z
|
|
13
|
+
dependencies: []
|
|
14
|
+
description: Calculates the percentagem in a time frame considering the current time
|
|
15
|
+
email: info@luisramalho.com
|
|
16
|
+
executables: []
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- lib/percentage_in_time.rb
|
|
21
|
+
homepage: http://rubygems.org/gems/percentage_in_time
|
|
22
|
+
licenses:
|
|
23
|
+
- MIT
|
|
24
|
+
post_install_message:
|
|
25
|
+
rdoc_options: []
|
|
26
|
+
require_paths:
|
|
27
|
+
- lib
|
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
29
|
+
none: false
|
|
30
|
+
requirements:
|
|
31
|
+
- - ! '>='
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
35
|
+
none: false
|
|
36
|
+
requirements:
|
|
37
|
+
- - ! '>='
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0'
|
|
40
|
+
requirements: []
|
|
41
|
+
rubyforge_project:
|
|
42
|
+
rubygems_version: 1.8.25
|
|
43
|
+
signing_key:
|
|
44
|
+
specification_version: 3
|
|
45
|
+
summary: Calculates the percentagem in a time frame
|
|
46
|
+
test_files: []
|
|
47
|
+
has_rdoc:
|